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 | ||
| conftest.py | ||
| test_account.py | ||
| test_app_describe_query.py | ||
| test_app_list_query.py | ||
| test_app_payloads.py | ||
| test_app_run_dispatch.py | ||
| test_app_run_streaming.py | ||
| test_apps_permitted_external_query.py | ||
| test_audit_app_run.py | ||
| test_contract.py | ||
| test_cors.py | ||
| test_device_approve_deny.py | ||
| test_device_code.py | ||
| test_device_lookup.py | ||
| test_device_sso.py | ||
| test_device_token.py | ||
| test_error_contract.py | ||
| test_health.py | ||
| test_human_input_form.py | ||
| test_input_schema.py | ||
| test_meta_version.py | ||
| test_models.py | ||
| test_oauth_sso_claims.py | ||
| test_oauth_sso_csrf.py | ||
| test_oauth_sso_host_header.py | ||
| test_pagination_envelope.py | ||
| test_workflow_events_openapi.py | ||
| test_workspaces_members.py | ||
| test_workspaces.py | ||