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
|
||
|---|---|---|
| .. | ||
| fixtures/workflow | ||
| helpers | ||
| integration_tests | ||
| test_containers_integration_tests | ||
| unit_tests | ||
| __init__.py | ||
| conftest.py | ||
| pytest_dify.py | ||
| seed_legacy_model_type_dirty_data.py | ||
| workflow_test_utils.py | ||