Repository navigation
fix: reject trailing newlines in preset IDs - #5188
Merged
Merged
Conversation
Require the entire preset ID to match the allowed character set and cover valid and malformed IDs with regression tests. Assisted-by: GitHub Copilot (model: GPT-6.1 Sol, autonomous) Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active issues are identified, and the change is narrowly focused on complete preset-ID validation with corresponding regression coverage.
No open issues 🎉
What changed in this PR
This pull request hardens preset manifest validation so preset IDs must fully match the lowercase alphanumeric-and-hyphen format, rejecting trailing and embedded newlines.
Changes:
- Replaced anchored
re.matchvalidation withre.fullmatch. - Added regression coverage for newlines, whitespace, path separators, empty IDs, and invalid casing.
- Added positive coverage for valid preset IDs.
| File | Description |
|---|---|
tests/specify_cli/presets/test_manifest.py |
Adds negative and positive regression coverage for preset ID formats. |
src/specify_cli/presets/_manifest.py |
Enforces complete-string validation for preset IDs. |
Review effort: Lite (auto)
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.
Description
Reject preset IDs containing trailing newlines by validating the entire string with
re.fullmatch. This preserves the existing lowercase alphanumeric-and-hyphen format and prevents malformed IDs from passing manifest validation.Add regression coverage for trailing and embedded newlines, whitespace, path separators, empty IDs, and valid IDs.
Testing
uv run specify --helpuv sync && uv run pytestUsed this worktree's own virtual environment instead of the
uv runcommands above, as recommended by CONTRIBUTING.md:uv sync --extra test- passed..venv/bin/python -m pytest tests/specify_cli/presets/test_manifest.py -q -k 'pack_id_format'before the fix - failed as expected: 1 failed, 12 passed; the trailing-newline case was accepted..venv/bin/python -m pytest tests/specify_cli/presets -qafter the fix - passed: 758 passed.LC_ALL=en_US.UTF-8 .venv/bin/python -m pytest tests -q- passed: 13,673 passed, 130 skipped, 63 warnings..venv/bin/specify --help- passed.git diff --check- passed.Sample-project and agent slash-command testing are not applicable to this manifest-validation fix.
AI Disclosure
AI disclosure: GitHub Copilot using GPT-6.1 Sol (model ID:
gpt-6.1-sol, runtime-default reasoning settings) assessed the validation defect, authored the fix and tests, ran automated validation, and prepared the commit and this PR on behalf of @mnriem. Execution was autonomous within user-approved scope; no human line-by-line review or manual testing is claimed.