Skip to content

Fix error variable scoping in generated code templates - #1

Open
Solver-Team wants to merge 1 commit into
mainfrom
solver/fix-error-variable-scoping
Open

Solver-Team wants to merge 1 commit into
mainfrom
solver/fix-error-variable-scoping

Conversation

@Solver-Team

Copy link
Copy Markdown
Owner

This PR fixes the issue with error variable reuse in generated API handlers by changing all error handling patterns to use scoped declarations.

Changes made:

  • Removed global err variable declarations at function scope
  • Converted all error checks to use scoped declarations (if err := ...)
  • Updated error handling patterns in all major framework templates:
    • Chi
    • Echo
    • Fiber
    • Gorilla
    • StdHTTP

The changes cover all parameter types:

  • Path parameters
  • Query parameters
  • Header parameters
  • Cookie parameters
  • JSON unmarshaling
  • Parameter binding
  • Styled parameter binding

This change prevents potential issues with error variable reuse and makes the generated code safer and more maintainable.

Created with Solver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant