mirror of
https://github.com/langgenius/dify.git
synced 2026-06-17 06:21:07 +08:00
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
|
||
|---|---|---|
| .. | ||
| auth | ||
| __init__.py | ||
| _audit.py | ||
| _contract.py | ||
| _errors.py | ||
| _input_schema.py | ||
| _meta.py | ||
| _models.py | ||
| account.py | ||
| app_run.py | ||
| apps_permitted_external.py | ||
| apps.py | ||
| files.py | ||
| human_input_form.py | ||
| index.py | ||
| oauth_device_sso.py | ||
| oauth_device.py | ||
| workflow_events.py | ||
| workspaces.py | ||