Fix: Fix revision commit endpoints silently discard unknown fields in…#4345
Fix: Fix revision commit endpoints silently discard unknown fields in…#4345justin212407 wants to merge 2 commits into
Conversation
… data Signed-off-by: justin212407 <charlesjustin2124@gmail.com>
|
@justin212407 is attempting to deploy a commit to the agenta projects Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughThe PR enforces strict validation on ChangesStrict validation enforcement
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related issues
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. 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 |
There was a problem hiding this comment.
Pull request overview
This PR tightens validation for workflow revision data payloads so unknown fields are rejected instead of silently discarded during commit operations.
Changes:
- Adds
extra="forbid"to SDKWorkflowRevisionData. - Adds a server-side strict
WorkflowRevisionDatawrapper. - Adds an application revision regression test for stale
ag_configpayloads returning 422.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
sdks/python/agenta/sdk/models/workflows.py |
Makes SDK workflow revision data reject unknown fields. |
api/oss/src/core/workflows/dtos.py |
Makes server workflow revision data reject unknown fields. |
api/oss/tests/pytest/acceptance/applications/test_application_variants_and_revisions.py |
Adds an acceptance test for application revision commit validation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
|
||
|
|
||
| class WorkflowRevisionData(BaseModel): | ||
| model_config = ConfigDict(extra="forbid") |
| class WorkflowRevisionData(BaseWorkflowRevisionData): | ||
| model_config = ConfigDict(extra="forbid") |
Summary
What changed:
Set
model_config = ConfigDict(extra="forbid")onWorkflowRevisionDatain both:sdks/python/agenta/sdk/models/workflows.py(SDK mirror)api/oss/src/core/workflows/dtos.py(server-side wrapper)This causes Pydantic to reject unknown fields in the
datapayload during revision commit, returning HTTP 422 with a validation error naming the offending field.Why:
Fixes issue #4315: revision commit endpoints (
POST /{applications,workflows,evaluators}/revisions/commit) silently discarded unknown top-level fields insidedata(e.g., the legacyag_configwrapper), while still returning HTTP 200 withcount: 1, creating a false sense of success. Users had no signal that their data was lost.What problem it solves:
WorkflowRevisionData(applications, workflows, evaluators, testsets, queries) now reject unknown fields uniformlyTesting
Verified locally
WorkflowRevisionDatawithextra="forbid"rejects stale payloads:{ "data": { "ag_config": { "prompt": { "messages": [{"role": "system", "content": "hi"}] } } } }ag_confignamed in the validation error.data.parameterscontinue to work (HTTP 200,count: 1).Added or updated tests
Added regression test
test_commit_application_revision_rejects_unknown_data_fieldinapi/oss/tests/pytest/acceptance/applications/test_application_variants_and_revisions.py:ag_configto/applications/revisions/commitag_configappears in the error detailThis covers applications; workflows and evaluators inherit the same DTO and will behave identically. Testsets and queries have their own
RevisionDataDTOs and would require separate test additions (out of scope for this PR per issue guidance).Demo
Before:
After:
Checklist
Related issues
data#4315 — Revisions commit endpoints silently discard unknown fields indataunsupported#4173 — Tracing ingest: per-span validation errors drop the whole batch instead of landing in unsupportedFiles Changed
sdks/python/agenta/sdk/models/workflows.py— Addedmodel_config = ConfigDict(extra="forbid")toWorkflowRevisionDataapi/oss/src/core/workflows/dtos.py— Wrapped SDKWorkflowRevisionDatawith explicitConfigDict(extra="forbid")api/oss/tests/pytest/acceptance/applications/test_application_variants_and_revisions.py— Added regression test for unknown field rejection