dify/api/controllers/openapi
GareArc f5c5dbaed5
feat(openapi): emit canonical ErrorBody on every /openapi/v1 error path
Install OpenApiErrorFormatter on the openapi blueprint's ExternalApi so
all non-2xx responses from /openapi/v1 carry the canonical ErrorBody shape
(code, message, status, optional details/hint). RFC 8628 device-flow
endpoints are unaffected — their flat {error: ...} shape is passed through
unchanged.

Also: set catch_all_404s=True when a formatter is present so unknown
routes return canonical JSON 404s (not Flask's default HTML 404).
Override _help_on_404 to suppress route suggestions, which would corrupt
the JSON contract and enumerate routes to unauthenticated callers.

Both behaviours are scoped by formatter presence — other blueprints that
construct ExternalApi without error_body_formatter are byte-identical.

Wire-level tests added to TestWireContract (3 tests, 18 total):
- 422 from @accepts validation carries code/status/details
- unknown-route 404 is canonical JSON without route suggestions
- device token POST returns RFC 8628 flat shape untouched by formatter
2026-06-10 02:48:38 -07:00
..
auth feat(api,cli): strict UUID validation for app-id and workspace-id (#37212) 2026-06-09 07:35:18 +00:00
__init__.py feat(openapi): emit canonical ErrorBody on every /openapi/v1 error path 2026-06-10 02:48:38 -07:00
_audit.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
_contract.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
_errors.py feat(openapi): add OpenApiErrorFormatter normalizing all error paths to ErrorBody 2026-06-10 02:26:19 -07:00
_input_schema.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
_meta.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
_models.py feat(api,cli): strict UUID validation for app-id and workspace-id (#37212) 2026-06-09 07:35:18 +00:00
account.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
app_run.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
apps_permitted_external.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
apps.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
files.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
human_input_form.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
index.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00
oauth_device_sso.py feat: adding dify cli (#36348) 2026-05-26 01:12:36 +00:00
oauth_device.py fix(api): expose device-flow approve rate limit as env var (#37083) 2026-06-05 02:56:23 +00:00
workflow_events.py feat(openapi): redesign auth pipeline with per-token-type routing (#36693) 2026-05-27 12:45:30 +00:00
workspaces.py refactor(openapi): unify request validation behind @accepts/@returns decorators (#37216) 2026-06-10 03:02:24 +00:00