Skip to content

Refused request bodies are never echoed back - #47

Merged
alexeybe1kin merged 1 commit into
mainfrom
fix/validation-no-echo
Nov 3, 2026
Merged

alexeybe1kin merged 1 commit into
mainfrom
fix/validation-no-echo

Conversation

@alexeybe1kin

Copy link
Copy Markdown
Collaborator

FastAPI's default 422 reply repeats the refused input. For a missing field pydantic's input is the whole body, so a malformed POST /auth/change-key or PUT /system/ai-runtime sent the current admin key (and a provider API key) back in the error body.

  • services/api/app/main.py: a RequestValidationError handler that returns only loc, msg and type per error, never input or ctx.
  • services/api/tests/test_validation_no_echo.py: change-key (missing and short new key), ai-runtime with an api_key, rotate-key and memory-reset with wrong types: 422, neither secret in the reply, each error is exactly loc/msg/type in the body.

Evidence: the new test failed 5/5 before the fix and passes 5/5 after; full suite 411 passed; ruff, file sizes and package boundaries pass.

🤖 Generated with Claude Code

FastAPI's default 422 reply repeats the refused input; for a missing field that
is the whole body, so a bad key change, key rotation, AI runtime update or
memory reset sent the current admin key (and a provider key) straight back.
Every route now returns only where and why (loc, msg, type).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@alexeybe1kin
alexeybe1kin merged commit 2c17e9e into main Nov 3, 2026
3 checks passed
@alexeybe1kin
alexeybe1kin deleted the fix/validation-no-echo branch November 3, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant