Skip to content

fix(scanner): accept trailing empty lines with explicit block indentation - #975

Draft
owenshen0907 wants to merge 1 commit into
goccy:masterfrom
owenshen0907:codex/explicit-block-indent-eof
Draft

owenshen0907 wants to merge 1 commit into
goccy:masterfrom
owenshen0907:codex/explicit-block-indent-eof

Conversation

@owenshen0907

@owenshen0907 owenshen0907 commented Oct 30, 2026 •

Copy link
Copy Markdown

Fixes #974.

At EOF, an explicitly indented block scalar such as key: |2- rejects trailing empty lines as under-indented content. Its final empty line is passed through the content-indentation check even though YAML permits those trailing lines. Validate EOF indentation only when the current line contains content, preserving the check for an under-indented final content character.

The regression tests check decoded values for 120 combinations of literal/folded style, clip/strip/keep, both indicator orders, LF/CRLF/CR, trailing blank lines and a final spaces-only line. All 120 fail on the unchanged source and pass with the fix. Another 18 cases keep rejecting under-indented content and indentation tabs, with and without a final newline.

Validation on the original macOS arm64 machine:

  • Go 1.24.13 and Go 1.26.3: go test -p=4 -race ./... and go test -p=4 -race ./testdata -modfile=testdata/go_test.mod pass.
  • Repository-pinned golangci-lint 2.1.2 with Go 1.24.13: 0 issues.
  • Go 1.26.3: go vet -p=4 ./..., go build -p=4 ./..., gofmt and git diff --check pass.
  • Existing FuzzUnmarshalToMap, bounded to 10 seconds and two workers: 369,622 executions, passed.
  • Other Go/OS and i386 CI matrices were not run locally.

The change concerns accepting valid scalar content at EOF. The separately open #973 concerns the starting-line position of already parsed block tokens. Two files change; dependencies and CI remain unchanged.

Base: master at edee2f91616c6d73112a13e7c0dbde72ce938877. See #974 for the minimal reproducer and YAML 1.2.2 references.

  • Describe the purpose for which you created this PR.
  • Create test code that corresponds to the modification.

AI assistance was used; reproduction, implementation and validation results were reviewed locally.

CI follow-up: run 41022753745, head 43f880dca1989ae9b183318245f129bd464dfc9e, completed with 17 successful jobs, one failure and seven fail-fast cancellations. The macOS/Go 1.21 job used macOS 26.6.2 and Go 1.21.13; dyld aborts the root test binary before tests start with missing LC_UUID load command. This matches the baseline loader failure previously reproduced on unchanged master for #954; it is not a failed assertion in the new regression. Linux race jobs for Go 1.21-1.24 and the i386 jobs pass. Hosted CI is not fully green, and cancelled jobs remain unverified. No workflow change or rerun was made.

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.71%. Comparing base (edee2f9) to head (43f880d).
❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #975      +/-   ##
==========================================
+ Coverage   80.65%   80.71%   +0.06%     
==========================================
  Files          22       22              
  Lines        6845     6846       +1     
==========================================
+ Hits         5521     5526       +5     
+ Misses        905      902       -3     
+ Partials      419      418       -1     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Explicitly indented block scalars reject trailing empty lines at EOF

2 participants