Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix: Generalize response status code handling#87

Merged
asteed merged 2 commits into
masterfrom
generalize-response-code
Feb 12, 2026
Merged

fix: Generalize response status code handling#87
asteed merged 2 commits into
masterfrom
generalize-response-code

Conversation

@asteed

@asteed asteed commented Feb 12, 2026

Copy link
Copy Markdown
Contributor

Generalize response status code handling

Summary

  • Normalize status codes sent to nginx
    In validator.lua, added convertToValidHttpStatusCode() so the value set to ngx.status is always a valid HTTP status (100–599). Extended codes (e.g. 401013) are mapped to their 3-digit base (e.g. 401); invalid or out-of-range values fall back to 500. exitFn now uses this before setting ngx.status.

  • Support extended status in error decorator
    In validatorsHandlerErrorDecorator.lua, when the response template is looked up by status, a normalized status (e.g. 401) may not match templates keyed by extended codes (e.g. 401013). The decorator now falls back to parsing the response body JSON and using error_code for the lookup, so the correct template and custom response are still applied for extended error codes.

Files changed

  • src/lua/api-gateway/validation/validator.lua – status normalization and use in exitFn
  • src/lua/api-gateway/validation/validatorsHandlerErrorDecorator.lua – fallback lookup by error_code from response body

@asteed asteed merged commit f71dce1 into master Feb 12, 2026
@asteed asteed deleted the generalize-response-code branch February 12, 2026 00:28
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.

2 participants