Read the shared steps' inputs as UTF-8 under the runner's empty locale

What does this MR do and why?

This follows !100 (merged), which read tier.txt as UTF-8 and left the other shared readers to this MR. The runner sets no locale, so Ruby reads files there as US-ASCII. Three shared steps still read their inputs with a bare File.read, and each one breaks on a non-ASCII character:

  • classify_change reads mr.json and mr_diff.json. On Ruby 3.4, json 3.0 refuses to parse a US-ASCII string with high bytes, and the regexps in the salvage path raise on one. So a title holding → makes the step refuse the run with "merge request unreadable; diff unreadable". Every Renovate update table holds an arrow, such as `28.5.1` → `28.5.2`, so on Ruby 3.4 the deps flow would refuse every merge request it sees.
  • choose_thread reads discussions.json and rescues to []. On Ruby 3.4, a note holding → hides the flow's own thread, so a re-run opens a new one.
  • extract_iid reads goal.txt. Its regexps raise on a US-ASCII string with high bytes on every Ruby, 2.6 included. So one curly apostrophe or accented letter in a trigger comment makes it exit non-zero, and the run ends without a label.

The four reads now use File.read(name, encoding: "UTF-8"), as approval_rules does. extract_iid also scrubs the goal, because it matches the goal rather than parsing it.

Three reads stay as they are, because each holds only ASCII. choose_thread reads labels.txt, which decide_labels writes, and marker.txt, which holds build_note's fixed signature. extract_iid reads project_url.txt, and a GitLab project path allows no other characters.

flows/mr-risk.yml embeds the shared extract_iid and choose_thread, so the fix reaches it too.

How to check

make check. Its lint stage fails on Style/SelectByKind in src/mr-risk/scripts/payload.rb:21, which comes from main and which !106 (closed) fixes. yamllint and every spec suite pass.

The new examples run the compiled steps with Workspace::NO_LOCALE from !100 (merged): three in spec/flow/integration and two in spec/deps/integration. Each of the four reads was reverted on its own, and at least one example failed each time. The choose_thread examples open their thread with each flow's own account, so they still pass once !95 (closed) makes choose_thread check the author.

Before After
flows/deps.yml 31797 bytes 31865 bytes
flows/flow.yml 40243 bytes, 717 under the cap 40311 bytes, 649 under the cap
flows/mr-risk.yml 37311 bytes 37359 bytes

Notes

  • This is stacked on !100 (merged), so it targets jecsanders-tier-txt-utf8. Retarget it to main once !100 (merged) merges.
  • Committed with SKIP=prettier, because the prettier hook can't install on this machine (nodeenv fails on a Node pre-release). The other hooks ran and passed.

🤖 Generated with Claude Code

Edited by Connor Sanders

Merge request reports

Loading
Loading