You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix: disable_auth crash, exception status mapping #280
register_openapi (foca/api/register_openapi.py): with disable_auth: true, the loop calls .pop("security", None) on every value of a Path Item, including path-level parameters (a list) and summary/description (strings), and fails with TypeError. The add_operation_fields branch already filters by _OPERATION_OBJECT_FIELDS. The existing tests only check isinstance(res, App), so they do not catch this.
foca/errors/exceptions.py: ServiceUnavailable is mapped to status 502. _problem_handler_json looks up type(exception) exactly, so subclasses of mapped exceptions (e.g. class TaskNotFound(NotFound)) return 500. Every handled exception is logged twice (the mapping dict, then the exception).
Proposal
Add an _iter_operations(spec) helper that yields only Operation Objects and use it in both branches.
Map ServiceUnavailable to 503; resolve the mapping along type(exception).__mro__; log once.
Test with tests/test_files/openapi_3_petstore_pathitemparam.original.yaml and disable_auth: true: no error, and the spec passed to add_api contains no security/securitySchemes (patch App.add_api and inspect).
Tests: ServiceUnavailable returns 503; a subclass of NotFound returns 404; one log record per handled exception.
Changelog notes the changed status codes.
Breaking changes
Status codes change for ServiceUnavailable (502 → 503) and for unmapped subclasses of mapped exceptions (500 → parent's status). Downstream custom mappings keep working.
Activity