Skip to content

Strip trailing whitespace from bakery.yaml writes#507

Merged
bschwedler merged 2 commits into
mainfrom
fix-trailing-ws-on-write
May 8, 2026
Merged

Strip trailing whitespace from bakery.yaml writes#507
bschwedler merged 2 commits into
mainfrom
fix-trailing-ws-on-write

Conversation

@bschwedler
Copy link
Copy Markdown
Contributor

@bschwedler bschwedler commented Apr 30, 2026

Summary

  • ruamel.yaml's round-trip serializer adds trailing spaces after YAML keys whose block scalar values continue on the next line (e.g. documentationUrl: \n https://...)
  • Every bakery create version / bakery patch version call triggers BakeryConfig.write(), which round-trips the entire bakery.yaml through ruamel — reintroducing the trailing whitespace
  • This causes pre-commit trailing-whitespace failures on every release commit from the bot, requiring manual cleanup each time

The fix dumps to a StringIO buffer, strips trailing whitespace with a regex, then writes the cleaned text to disk.

Test plan

  • Verified against images-connect/bakery.yaml — ruamel produces trailing space on documentationUrl: line; the fix removes it
  • Existing bakery tests pass

Instructs Claude Code to let the hook run, read its output on
failure, re-stage auto-fixed files, and commit again.
ruamel.yaml's round-trip serializer adds trailing spaces after
YAML keys whose block scalar values continue on the next line
(e.g. `documentationUrl: \n  https://...`). This causes
pre-commit trailing-whitespace failures every time bakery writes
bakery.yaml — most visibly on release commits from the bot.

Dump to a StringIO buffer first, strip trailing whitespace, then
write the cleaned text to disk.
@bschwedler bschwedler requested a review from ianpittwood as a code owner April 30, 2026 17:07
@github-actions
Copy link
Copy Markdown

Test Results

1 464 tests  ±0   1 464 ✅ ±0   8m 39s ⏱️ -10s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit 48dea80. ± Comparison against base commit 09bbcd1.

@bschwedler bschwedler added this pull request to the merge queue May 8, 2026
Merged via the queue into main with commit 4a035b5 May 8, 2026
23 checks passed
@bschwedler bschwedler deleted the fix-trailing-ws-on-write branch May 8, 2026 14:15
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.

2 participants