[6214] fix(api): Reject wrapped or empty session header edits - #6224
[6214] fix(api): Reject wrapped or empty session header edits#6224XonkelX wants to merge 2 commits into
Conversation
Reject unknown and fieldless session header update bodies before they reach the service, while preserving valid top-level name and description updates. Add DTO, in-process router, and acceptance regression coverage.
|
@XonkelX is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
|
✅ Thanks @XonkelX! This PR now meets the contribution requirements and has been reopened. A maintainer will review it soon. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughSummary by CodeRabbit
WalkthroughThe session stream header DTO now rejects unknown fields and empty updates. Acceptance and unit tests verify HTTP 422 responses, unchanged stream names, and skipped service calls for invalid payloads. ChangesSession stream header validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Merge Risk: ⚪ Minimal · up to The change rejects wrapped or empty session-header edits before they reach the service while preserving valid updates and existing clear-title behavior; no actionable merge-blocking risk remains after normal checks and review. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
PUT /sessions/streams/headeraccepted wrapped or empty JSON because every header field is optional and Pydantic ignored unknown keys. Those requests reached the service as an empty edit, returned 200, and changed nothing.This change makes the endpoint-specific
SessionStreamHeaderEditreject unknown top-level keys and require at least one recognizednameordescriptionfield. Validation now returns 422 before the service runs, while valid top-level updates, partial updates, explicitNone, and the existing empty-string clear-title action remain compatible.Fixes #6214.
Related prior attempt: #6215 was automatically closed before maintainer review. Thanks to @Hashim1999164 for documenting the same validation direction.
Testing
Verified locally
uv sync --lockedruff format --check— 2,098 files already formattedruff check— passedpytest oss/tests/pytest/unit/sessions -q— 477 passed, 41 skipped because local Postgres is not configurednameanddescriptionat the request-body top levelAdded or updated tests
name=Nonecompatibility.{}and{"header": {...}}return 422 beforeset_headeris called.QA follow-up
AGENTA_API_URL/AGENTA_AUTH_KEYconfigured./magainst that stack.Demo
Request/response contract after this change:
The automated in-process API demo for both invalid requests passes in
test_stream_header_rejects_noop_bodies_before_calling_service.Checklist