Repository navigation
Fix main: read the settings route's contract off its parse tree, not its text - #9591
Merged
Merged
Conversation
`Repo tests (CPU)` has been red on main since #9492 (1f475d7) on test_the_backfill_fills_in_fields_rather_than_skipping_known_keys. The rule the test guards did not change. #9492 added a third name to the `model_dump(exclude = {...})` set in `update_openai_auto_switch_override`, the formatter then split the set one name per line, and assert '"remove", "fill_absent_fields"' in route no longer matched, because `route` is the raw source text of studio/backend/routes/settings.py and the two names now have a newline and sixteen spaces between them. Both names are still excluded. Nothing about the write-mode-is-not-a-saved-field rule moved. This is the third failure of this shape on main in as many days (#9578, #9579), so pinning a new literal only moves the next one into the future. A test that has to be re-edited whenever a set literal is reflowed is not testing the thing it names. The frontend greps in this file have no parser to hand. The backend does. Three helpers read the rule out of settings.py's AST instead: - `_model_dump_exclusions` returns the names the one `model_dump(exclude = ...)` in a given function leaves out. Exactly one such call, or the answer would be a union and a name dropped from the call that matters could hide behind another. - `_annotated_field` returns the annotation and literal default of a field on a pydantic model, so "declared as a bool defaulting to False" is asserted as that rather than as a substring. - `_forwarded_keywords` returns the keyword arguments passed as `name = payload.name`, which is the part the storage layer depends on. Each raises rather than returning empty when it cannot find what it was pointed at, so a renamed handler or field reddens here instead of passing vacuously. Verified by mutation against the repaired test, one at a time on settings.py: | Mutation | Result | |---------------------------------------------------|--------| | unmodified main | pass | | `"fill_absent_fields"` dropped from the exclude set| fail | | the exclude set reflowed onto one line, reordered | pass | | the payload field defaulted to True | fail | | `fill_absent_fields` no longer forwarded to the db | fail | | the route handler renamed | fail | | the payload field renamed | fail | The reflow is the case that caused this outage and is now the only one that stays green; every mutation that actually breaks the contract still reddens. Local: `tests/studio/test_model_picker_contracts.py` 187 passed, was 186 passed 1 failed. No production code changed.
Member
Author
|
@codex review |
|
Codex Review: Didn't find any major issues. Nice work! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
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.
Repo tests (CPU)has been red on main since #9492 (1f475d7), ontests/studio/test_model_picker_contracts.py::test_the_backfill_fills_in_fields_rather_than_skipping_known_keys.Every open PR inherits it. Run 32659798911.
What actually broke
The rule the test guards did not change. #9492 added a third name,
mirrors_server_tuning, to themodel_dump(exclude = {...})set inupdate_openai_auto_switch_override. The formatter then split that set one nameper line, and this assertion stopped matching:
routeis the raw source text ofstudio/backend/routes/settings.py, so thetwo names now have a newline and sixteen spaces between them. Both are still
excluded, and write modes still stay out of
saved_fields. #9492 is correcthere and the test was stale.
Why not just re-pin the literal
This is the third failure of this exact shape on main in as many days: #9579
sliced
setup.shat a keyword that had been demoted fromiftoelif, and#9578 compared two clock origins. Pinning a new literal only moves the next one
into the future. A test that has to be re-edited whenever a set literal is
reflowed is not testing the thing it names.
The fix
The frontend greps in this file have no parser to hand. The backend does. Three
helpers read the rule out of
settings.py's AST:_model_dump_exclusionsreturns the names the onemodel_dump(exclude = ...)in a given function leaves out. Exactly one such call is required, or the
answer would be a union across calls and a name dropped from the call that
matters could hide behind another.
_annotated_fieldreturns the annotation and literal default of a pydanticfield, so "declared as a bool defaulting to False" is asserted as that rather
than as a substring.
_forwarded_keywordsreturns the keyword arguments passed asname = payload.name, which is the part the storage layer depends on.Each raises rather than returning empty when it cannot find what it was pointed
at, so a renamed handler or field reddens here instead of passing vacuously.
Anti-vacuity evidence
One mutation at a time against
settings.py, running the repaired test:"fill_absent_fields"dropped from the exclude setTruefill_absent_fieldsno longer forwarded to the db callThe reflow is the case that caused this outage and is now the only one that
stays green. Every mutation that actually breaks the contract still reddens.
Local run
tests/studio/test_model_picker_contracts.py: 187 passed, was 186 passed and 1failed. No production code is touched by this PR.
The second failure on the same run,
(Python 3.13)/Backend tests, is adifferent root cause and is fixed separately.