Repository navigation
fix(OMN-9593): formalize string schema_version exemption for ticket contracts - #449
Conversation
|
Warning Rate limit exceeded
To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR extends a pre-commit validation hook to detect hardcoded version strings across both Python and YAML files. The validation script now checks Python Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
tests/unit/test_validate_string_versions.py (1)
58-100: Add regression tests for quote-style and path-boundary edge cases.Please add tests for (1)
'1.2.3'single-quoted YAML versions and (2) a non-exempt path likemycontracts/OMN-9593.yamlto lock in the intended policy boundaries.Suggested test additions
class TestYamlStringVersion: + def test_detects_single_quoted_version_in_yaml(self, tmp_path: Path) -> None: + p = _write(tmp_path, "config.yaml", "version: '1.0.0'\n") + assert len(_has_string_version_in_yaml(p)) == 1 + class TestTicketContractExemption: + def test_mycontracts_path_not_exempt(self, tmp_path: Path) -> None: + p = _write( + tmp_path, + "mycontracts/OMN-9593.yaml", + 'schema_version: "1.0.0"\n', + ) + assert _is_ticket_contract(p) is False + assert len(_has_string_version_in_yaml(p)) == 1🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@tests/unit/test_validate_string_versions.py` around lines 58 - 100, Add two new unit tests: one in TestYamlStringVersion that writes a YAML file containing a single-quoted version string like 'version: \'1.2.3\'' and asserts _has_string_version_in_yaml(path) returns a violation (len==1 and contains "ModelSemVer"); and one in TestTicketContractExemption that writes a file at path "mycontracts/OMN-9593.yaml" with schema_version: "1.0.0" and asserts _is_ticket_contract(path) is False and _has_string_version_in_yaml(path) reports the string-version violation; use the existing helpers (_write, _has_string_version_in_yaml, _is_ticket_contract) and mirror naming/structure of the surrounding tests.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@scripts/validation/validate_string_versions.py`:
- Around line 34-38: The current TICKET_CONTRACT_GLOB and _is_ticket_contract
allow false positives and fail on Windows paths; update TICKET_CONTRACT_GLOB to
be anchored (e.g. r"^contracts/OMN-\d+\.yaml$") and change _is_ticket_contract
to operate on Path.as_posix() and use fullmatch/match instead of search, so it
only matches a path that exactly equals "contracts/OMN-<digits>.yaml" across
platforms; reference TICKET_CONTRACT_GLOB and _is_ticket_contract when making
these changes.
- Line 30: The _SEMVER_RE currently only matches unquoted or double-quoted
versions; update the regex _SEMVER_RE to accept optional single or double quotes
around the SemVer (e.g., allow leading and trailing ' or "), then update any
usage that relies on this pattern (the validation at the usage site referenced
around line 114) so it still strips or validates the captured groups correctly
(ensure the groups capture the numeric major.minor.patch regardless of quoting).
Use the symbol _SEMVER_RE to locate the change and adjust the validation logic
where it's applied.
---
Nitpick comments:
In `@tests/unit/test_validate_string_versions.py`:
- Around line 58-100: Add two new unit tests: one in TestYamlStringVersion that
writes a YAML file containing a single-quoted version string like 'version:
\'1.2.3\'' and asserts _has_string_version_in_yaml(path) returns a violation
(len==1 and contains "ModelSemVer"); and one in TestTicketContractExemption that
writes a file at path "mycontracts/OMN-9593.yaml" with schema_version: "1.0.0"
and asserts _is_ticket_contract(path) is False and
_has_string_version_in_yaml(path) reports the string-version violation; use the
existing helpers (_write, _has_string_version_in_yaml, _is_ticket_contract) and
mirror naming/structure of the surrounding tests.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 434edb9a-45ce-4770-bc05-3e06cc8a20db
📒 Files selected for processing (3)
.pre-commit-config.yamlscripts/validation/validate_string_versions.pytests/unit/test_validate_string_versions.py
, #452 (#1455) * contracts(OMN-11854): add OCC evidence for omninode_infra PRs #449, #451, #452 - contracts/OMN-11770.yaml — CI gate wiring (PR #449) - contracts/OMN-11854.yaml — prod deploy tag fix (PR #451) - contracts/OMN-10278.yaml — adds dod-omninode-infra-pr-452 for tag-based TF discovery (PR #452) - Receipt files for all three PRs * contracts(OMN-11854): update self-bound receipts with OCC PR #1455 number * contracts(OMN-11854): add missing commit_sha + contract_sha256 to self-bound receipts * contracts(OMN-11854): update OMN-10278 receipt from pr-452 to pr-456 (renamed branch) * contracts(OMN-11854): add PR #456 evidence to OMN-11854 contract Add dod-omninode-infra-pr-456 receipt and evidence item to OMN-11854 contract for omninode_infra PR #456 (tag-based network discovery). Update dod-occ-pr receipt with new contract_sha256. * contracts(OMN-11854): rename PR evidence from #456 to #457 (branch identity fix) PR #456 had wrong branch name (omn-10278 prefix); closed in favor of #457 with correct jonah/omn-11854-* branch for identity binding. Update contract, receipt dir, and contract_sha256 throughout. * contracts(OMN-11854): rename PR #451→#458 evidence (branch identity fix) PR #451 had branch jonah/fix-prod-deploy-tag (no OMN ticket); closed in favor of #458 with jonah/omn-11854-fix-prod-deploy-tag. Update contract, receipt dir, and contract_sha256 throughout. * contracts(OMN-11854): fix yamlfmt + unquote ticket_id in receipts yamlfmt reformats probe_stdout literal blocks; strip YAML quotes from ticket_id fields so the contract grep checks (^ticket_id: OMN-XXXX$) match the actual file content. * contracts(OMN-11854): apply yamlfmt to all branch-modified YAML files * contracts(OMN-11854): update contract_sha256 after yamlfmt reformat yamlfmt reformatted OMN-11854.yaml, changing its hash. Update all three OMN-11854 receipts with the new sha256:2848b28f... hash.
Summary
validate-yaml(accepts stringschema_version) andvalidate-string-versions(rejects it)schema_version, enforced byModelTicketContract.field_validatorvalidate_string_versions.pyto cover YAML files with explicitcontracts/OMN-*.yamlexemptiontypes: [python]totypes_or: [python, yaml]Summary by CodeRabbit
Release Notes
New Features
Tests