Read tier.txt as UTF-8, so a non-ASCII reason no longer drops the note

What does this MR do and why?

The runner sets no locale, so Ruby reads files there as US-ASCII. build_note, decide_labels and raise_below_one read tier.txt with a bare File.read. So one reason holding a non-ASCII character, such as 1.65.1 → 1.65.3 or café.go, makes build_note post only its fallback line: "The labels on this merge request are the assessment." This came up during #40, but the model's own reasons already trigger it.

The three steps now read tier.txt the way approval_rules does, File.read(name, encoding: "UTF-8").scrub. raise_below_one also reads mr_diff.json as UTF-8.

The labels stay right on Ruby 2.6, which strips such a string. On Ruby 3.4 and 4.0, String#strip raises on it, and json 3.0's parser does too. So there, decide_labels and raise_below_one also exit non-zero.

How to check

make check. The new examples in spec/deps/integration and spec/flow/integration run the compiled steps with LANG, LC_ALL, LC_CTYPE and RUBYOPT unset, and they fail without the fix. Workspace#run now takes an env, and the existing approval_rules example uses it too.

Until !106 (closed) lands, make check on this MR merged with main fails at lint. RuboCop reports main's own offense in src/mr-risk/scripts/payload.rb, which this MR does not touch. The specs pass.

Sizes against main at 2ee2e4fe, with this MR merged in:

Before After
flows/deps.yml 31717 bytes 31797 bytes
flows/flow.yml 40191 bytes, 769 under the cap 40243 bytes, 717 under the cap

flows/mr-risk.yml is unchanged. The MR Risk Labeler has its own build_note and decide_labels, and reads no tier.txt.

Notes

  • In #40's stage, !99 (closed), keep_higher_tier writes the judge's reason into tier.txt as Upstream: <reason>. A non-ASCII character in that reason would leave the note at its fallback line, so this MR should merge before !99 (closed).
  • Not fixed here: classify_change reads mr.json and mr_diff.json bare, choose_thread reads discussions.json bare, and extract_iid reads goal.txt bare. !101 (closed), stacked on this MR, reads those four as UTF-8. Under an empty locale on Ruby 3.4, a title holding → makes classify_change refuse the run with "merge request unreadable".
  • 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