Fix: fail update_constraints.sh --check when the header records no single snapshot date - #213
Open
AmaadMartin wants to merge 2 commits into
Open
Fix: fail update_constraints.sh --check when the header records no single snapshot date#213AmaadMartin wants to merge 2 commits into
AmaadMartin wants to merge 2 commits into
Conversation
Check mode reads the snapshot date out of the file's own header. When the header records no date, or several, the extraction yields a value the shell cannot use: an empty one drops --exclude-newer and re-resolves the pins against the live index, and a multi-line one expands into stray argv. Both report the file as OUT OF DATE, which is the wrong diagnosis and the wrong remedy. Require exactly one YYYY-MM-DD in check mode, and reject the file before any resolution runs. Update mode owns the date and is unchanged.
AmaadMartin
force-pushed
the
fix/update-constraints-check-unreadable-snapshot-date
branch
from
August 11, 2026 02:57
488c398 to
86e548b
Compare
AmaadMartin
changed the base branch from
feat/restore-dependency-constraints
to
main
August 11, 2026 02:57
The surrounding script comments are one line each. Keep the intent and drop the notes about bash mechanics, which the echo block below already states to the reader.
This was referenced Aug 11, 2026
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.
Please ensure you have read the contribution guide before creating a pull request.
Link to Issue or Description of Change
Link to an existing issue (if applicable):
Or, if no issue exists, describe the change:
Problem:
update_constraints.sh --checkre-resolves eachconstraints-<ver>.txtagainst the snapshot date recorded in the file's own header. When the header records no date, the substitution yields an empty string, the--exclude-newerflag is dropped, and the pins are re-resolved against the live index; every release published since then reads as drift. When the header records two dates, the two-line value expands into stray argv (2026-03-04: command not found). Both cases end in❌ <file> is OUT OF DATE!, which is the wrong diagnosis and points the reader at a remedy that launders an unreadable header into a new supply-chain baseline.Solution: In check mode the recovered value must match exactly one
YYYY-MM-DDtoken. A file that fails the match gets its own message, sets the exit code and is skipped before any resolution runs, so the live index is never consulted for it. The remaining versions are still checked. Update mode owns the date and is unchanged, which makes theif [ -n "$date_to_use" ]guard dead code, so it is removed.Collision check: I listed all 100 open pull requests on the fork. #149 rewrites the same block, but it also redesigns update mode, so this change stays independent of it and rebases cleanly in either order. #159, #163 and #195 touch other parts of the script.
Testing Plan
Please describe the tests that you ran to verify your changes. This is required for all PRs that are not small documentation or typo fixes.
Unit Tests:
pytest tests/unittests/scripts/test_update_constraints.py -q→ 7 passed.The tests drive the real script through
bashagainst a stubuvonPATH, so nothing is mocked and no test reaches PyPI.Proof the tests can fail. Against the unmodified script, 4 failed and 3 passed. The other three pin behaviour this change must preserve, so I mutated each separately:
assert 0 == 1on the exit code^[0-9]{4}-[0-9]{2}$test_check_mode_resolves_against_the_recorded_snapshot_datetest_update_mode_regenerates_a_file_with_a_malformed_headercontinuetest_check_mode_reports_missing_files_without_resolvingUpdate mode is unchanged, measured rather than asserted. I ran the old script and the new one over identical trees with a stub
uv, one file carrying a stripped header. Both make 5uvcalls, both resolve againsttoday - 4d, both rewrite all five files and exit 1. The two transcripts differ only in thediff -utimestamps.Manual End-to-End (E2E) Tests:
Please provide instructions on how to manually test your changes, including any necessary setup or configuration.
I ran this against the committed
constraints-3.12.txtwith nouvonPATH, so any resolution attempt would be visible. A stripped header and two concatenated headers both print❌ constraints-3.12.txt has no single '--exclude-newer YYYY-MM-DD' snapshot date in its header,, exit 1 and leave the file byte-unchanged, with nouvcall. The control run with the real header still reportsFound generation command: ... --exclude-newer 2026-07-24 ..., so a well-formed file is not rejected.CI on this PR: all 5 Unit Tests jobs, all 5 A2A jobs and all 4 Mypy jobs pass. The Pre-commit Linter job fails on the
update-constraintshook withfiles were modified by this hook. That failure is pre-existing and unrelated: PR #212 reproduces it on a branch that touches neither the script nor the constraints files. The hook runs the script in update mode over the committed files, which is the concern of #163.Checklist