🐛 Keep leading-zero sexagesimal values as strings under YAML 1.1#174
Conversation
|
Warning Review limit reached
Next review available in: 43 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
df23bb3 to
a72cb04
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes YAML 1.1 scalar resolution so a leading-zero sexagesimal value such as 03:30 (a common time-of-day) stays the string "03:30" instead of being silently converted to the base-60 integer 210. It enforces the YAML 1.1 integer sexagesimal production [-+]?[1-9][0-9_]*(:[0-5]?[0-9])+ in parse_sexagesimal_int, rejecting a leading-zero first segment and an oversized/out-of-range later segment. This aligns YAMLRocks with PyYAML and ruamel and affects both OPT_YAML_1_1 and OPT_PYYAML_COMPAT (float sexagesimal parsing is intentionally left untouched, since its spec production allows a leading zero).
Changes:
- Enforce the leading
[1-9]first-segment and[0-5]?[0-9]later-segment rules inparse_sexagesimal_int, keeping leading-zero/oversized forms as strings. - Update the Rust emitter unit test to use a genuine sexagesimal value (
10:20:30) since01:02:03is now a string. - Add Python coverage for leading-zero and out-of-range sexagesimal values staying strings under both 1.1 schemas.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
src/resolver/yaml11.rs |
Core fix: enforce the YAML 1.1 int sexagesimal production so leading-zero/oversized segments resolve as strings; updated unit-test expectations. |
src/encode/mod.rs |
Updated emitter test values from 01:02:03 to 10:20:30; a nearby explanatory comment still references the old value. |
tests/core/test_yaml_1_1.py |
Adds parametrized coverage for leading-zero and out-of-range sexagesimal values staying strings under OPT_YAML_1_1 and OPT_PYYAML_COMPAT. |
The main concern is that the behavior change also affects emitter quoting (resolves_to_number), so existing assertions in tests/core/test_dumps.py, tests/roundtrip/test_edge_cases.py, and the verified doc example in docs/reference/options.md that treat 01:02:03 as a quoted 1.1 sexagesimal number are now incorrect and would fail CI, but were not updated here.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
a72cb04 to
3918c95
Compare
3918c95 to
0ef56d2
Compare
The YAML 1.1 integer sexagesimal production is `[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+`: the leading segment must start 1-9, and every later segment is one or two base-60 digits. `parse_sexagesimal_int` only rejected a per-segment sign, so a time of day like 03:30 parsed as the base-60 integer 210 under OPT_YAML_1_1 and OPT_PYYAML_COMPAT, silently corrupting a common Home Assistant/ESPHome/Ansible value. PyYAML and ruamel keep it a string. Enforce the spec production: reject a leading-zero first segment (03:30, 0:30, 00:00, 023:30) and an oversized later segment (1:030), so all stay strings. 1:30, 90:00, and 1:2:3 still resolve as base-60. A shared dump test that used 01:02:03 as a sexagesimal example now uses 10:20:30, since 01:02:03 is correctly a string.
0ef56d2 to
5347b09
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #174 +/- ##
==========================================
+ Coverage 92.37% 92.53% +0.15%
==========================================
Files 40 40
Lines 11201 11441 +240
==========================================
+ Hits 10347 10587 +240
Misses 854 854 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Breaking change
Under
OPT_YAML_1_1andOPT_PYYAML_COMPAT, a leading-zero sexagesimal value like03:30now resolves to the string"03:30"instead of the base-60 integer210. This matches PyYAML and ruamel. Anyone who (incorrectly) relied on03:30becoming210will see the string instead, but that was silent data corruption of a common time-of-day value, so the change is a fix. The default YAML 1.2 schema never resolved sexagesimal and is unaffected.Proposed change
The YAML 1.1 integer sexagesimal production is
[-+]?[1-9][0-9_]*(:[0-5]?[0-9])+: the leading segment must start1-9, and every later segment is one or two base-60 digits.parse_sexagesimal_intonly rejected a per-segment sign, so03:30parsed as210, and1:030as60. A time of day in a Home Assistant / ESPHome / Ansible config silently became an integer.This enforces the spec production: a leading-zero first segment (
03:30,0:30,00:00,023:30) and an oversized later segment (1:030) now stay strings. Genuine base-60 values (1:30,90:00,1:2:3) still resolve. A shared 1.1 dump test that used01:02:03as a sexagesimal example now uses10:20:30, since01:02:03is correctly a string.Type of change
Additional information
Checklist
uv run pytestpasses locally. A pull request cannot be merged unless CI is green.uv run ruff check .anduv run ruff format --check .pass.cargo fmt --checkandcargo clippy --all-targets -- -D warningspass.