refactor(models): reject legacy action values at API boundaries#163
Open
refactor(models): reject legacy action values at API boundaries#163
Conversation
Split action validation into strict (validate_action) for API input boundaries and lenient (normalize_action) for internal read paths. ControlAction.decision and EventQueryRequest.actions now reject allow/warn/log with a clear error. ControlMatch and ControlExecutionEvent still normalize legacy values from historical DB rows.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
validate_action) for API input boundaries and lenient (normalize_action) for internal read pathsControlAction.decisionnow rejectsallow/warn/logwith a clear error — onlydeny,steer,observeare accepted when creating or updating controlsEventQueryRequest.actionsnow rejects legacy values in query filtersControlMatchandControlExecutionEventstill normalize legacy values from historical DB rows vianormalize_actionexpand_action_filterunchanged — still expandsobserveto include legacy values for SQL queries against old event dataFollows #161 which introduced the
observeaction and normalization layer.Test plan
models/tests/test_actions.py— 43 tests covering strict validation, lenient normalization, Pydantic model boundaries, and query expansionserver/tests/test_observability_models.py— updated to verify legacy rejection in query filtersengine/tests/test_core.py— 49 tests pass (unchanged)sdks/python/tests/test_control_decorators.py— 35 tests pass (unchanged)make lintandmake typecheckpass🤖 Generated with Claude Code