You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 3e4935b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(server): require control data on create (#139)
## Summary
- require `data` on `PUT /api/v1/controls` instead of allowing name-only
shell control creation
- validate the control definition before insert so invalid create
requests return `422` and persist nothing
- update Python SDK, TypeScript SDK, UI API types, tests, and shipped
examples to use the single-request atomic create flow
- keep legacy empty-control behavior only for existing rows/read paths
covered by targeted compatibility tests
## Bug Explanation
For a create-with-definition flow, the client did:
1. `PUT /api/v1/controls` with just `name`
2. the server inserted an empty shell control
3. `PUT /api/v1/controls/{id}/data` with the definition
4. if step 3 returned `422`, the empty shell from step 2 was still in
the DB
That is the concrete bug this PR fixes. Invalid create requests were not
atomic, so callers could end up with persisted empty `{}` controls even
though the overall create-with-definition flow had failed.
One nuance: the agent association part was caller-flow dependent. The
root server-side invariant failure was the persisted shell control after
invalid data, and that is what this change removes.
## Testing
- `cd server && uv run pytest tests/test_controls.py
tests/test_controls_additional.py tests/test_controls_validation.py
tests/test_agents_additional.py tests/test_auth.py
tests/test_control_compatibility.py tests/test_error_handling.py
tests/test_evaluation_e2e.py tests/test_evaluation_error_handling.py
tests/test_init_agent.py tests/test_init_agent_conflict_mode.py
tests/test_new_features.py tests/test_policies.py
tests/test_policy_integration.py -q`
- `make lint`
- `make typecheck`
- `make sdk-ts-build`
- `make ui-typecheck` (still fails on pre-existing unrelated UI
dependency/type issues)
Closes#138
0 commit comments