Skip to content

Sampler: pass template names newline-separated so spaced account template names survive - #37

Open
michieldegezelle wants to merge 3 commits into
mainfrom
sampler-newline-separated-template-names
Open

Sampler: pass template names newline-separated so spaced account template names survive#37
michieldegezelle wants to merge 3 commits into
mainfrom
sampler-newline-separated-template-names

Conversation

@michieldegezelle

@michieldegezelle michieldegezelle commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

Account template identifiers are directory names and routinely contain spaces (account_templates/Investment- and depreciation details). The handles / account_templates inputs were documented and encoded as space-separated strings, then deliberately word-split into CLI args — so -at received Investment-, and, depreciation, details and the run died:

[error] Config file for account template "Investment-" not found

Hit live in lu_market: https://github.com/silverfin/lu_market/actions/runs/30612771053 (the PR under review changed exactly one file, inside that template).

Change

Both inputs are now one name per line, and the arg arrays are built with mapfile so each line becomes exactly one argv entry. This is already the convention in this repo's own run_tests.yml (TEMPLATE_BUCKETS, with a comment saying why) — the sampler was the only place that regressed to space-joining. firm_ids stays space-separated; it's numeric, so the SC2086 split there is still intentional.

Two supporting bits in the same area:

  • The attempt log line is %q-quoted, so a name containing spaces is visibly one argument.
  • The PR comment renders the names as individually code-quoted, comma-separated entries — a multi-line value inside one backtick pair renders as garbage.

⚠️ Input contract change for callers

A caller still passing a space-joined list now fails loudly (Config file for account template "..." not found) instead of silently sampling templates nobody asked for. I deliberately did not add a space-splitting fallback: for names containing spaces it cannot be made correct, and the loud failure is the honest outcome.

Input descriptions and the README input list are updated to say one per line. The only callers today are the lu_market / nl_market wrappers, which currently run inlined forks of this job (pinned to silverfin-cli's unmerged sampler-compact-diff-v2 branch); their matching fixes are silverfin/lu_market#785 and silverfin/nl_market#914. When those forks are reverted to uses: after silverfin-cli #265 merges, this fix means they don't regress — but the newline-emitting classify half lives in the market repos, so the two halves must land together.

Testing

The name-splitting logic was verified in bash against the real lu_market names (Investment- and depreciation details + Loan details → 3 argv entries, spaces intact); YAML validated. Not yet exercised in a live sampler run — see the market PRs for that.

🤖 Generated with Claude Code

Account template identifiers are directory names and routinely contain
spaces ("Investment- and depreciation details"). The sampler encoded the
handles/account_templates inputs as space-separated strings and then
word-split them into CLI args, so -at received "Investment-", "and",
"depreciation", "details" and the run died with:

  [error] Config file for account template "Investment-" not found

Switch both inputs to one-name-per-line and build the arg arrays with
mapfile, so each line becomes exactly one argv entry. This is already the
convention in run_tests.yml (TEMPLATE_BUCKETS) — the sampler was the only
place that regressed to space-joining. firm_ids stays space-separated;
it's numeric.

Also render the names in the PR comment as individually code-quoted,
comma-separated entries (a multi-line value inside one backtick pair
renders as garbage) and %q-quote the attempt log line so a spaced name is
visibly one argument.

Callers must now pass these inputs newline-separated — README and the
input descriptions updated accordingly.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

You’ve reached a temporary PR review limit under our Fair Usage Limits Policy.

Your recent review volume is higher than typical usage, so adaptive limits are currently applied.

Next review available in: 30 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: af51ab11-9957-40ad-a487-10af61f7465e

📥 Commits

Reviewing files that changed from the base of the PR and between b8ddd44 and 5b88bf3.

📒 Files selected for processing (1)
  • .github/workflows/run_sampler.yml

Walkthrough

The sampler workflow now accepts newline-separated handles and account-template names. It preserves spaces in CLI arguments, shell-escapes attempt logs, and renders each value separately in PR comments. The README documents the new format and retains space-separated firm_ids.

Changes

Sampler input handling

Layer / File(s) Summary
Input contract and CLI argument construction
.github/workflows/run_sampler.yml, README.md
Inputs now use one handle or account-template name per line. Nonblank lines become individual CLI arguments, including names with spaces.
Argument observability
.github/workflows/run_sampler.yml
Attempt logs use %q quoting. PR comments render each handle or account template as a separate inline code item.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly summarizes the main change: passing template names newline-separated to preserve spaces.
Description check ✅ Passed The description clearly explains the issue, implementation, contract change, affected callers, documentation updates, and testing status.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch sampler-newline-separated-template-names

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
.github/workflows/run_sampler.yml (1)

173-188: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add an automated argv-boundary regression test.

Test a two-line value containing Investment- and depreciation details. Assert that the constructed array contains two names after the -h or -at flag. This protects the primary fix from a future return to shell word splitting.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/run_sampler.yml around lines 173 - 188, Add an automated
regression test for the argument construction around HANDLE_ARGS and
ACCOUNT_ARGS using a two-line input that includes “Investment- and depreciation
details”; assert the resulting array preserves exactly two names after the
relevant -h or -at flag, confirming newline-based parsing does not regress to
shell word splitting.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/run_sampler.yml:
- Around line 375-380: Update the fmtNames formatter used by the HANDLES and
ACCOUNT_TEMPLATES PR comment entries to escape or safely encode backticks within
each trimmed name before wrapping it in Markdown code delimiters. Preserve the
existing newline splitting, whitespace filtering, and comma-separated rendering
behavior.

---

Nitpick comments:
In @.github/workflows/run_sampler.yml:
- Around line 173-188: Add an automated regression test for the argument
construction around HANDLE_ARGS and ACCOUNT_ARGS using a two-line input that
includes “Investment- and depreciation details”; assert the resulting array
preserves exactly two names after the relevant -h or -at flag, confirming
newline-based parsing does not regress to shell word splitting.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4a12af9a-2206-473b-bef9-23470718c1ab

📥 Commits

Reviewing files that changed from the base of the PR and between cecff38 and b8ddd44.

📒 Files selected for processing (2)
  • .github/workflows/run_sampler.yml
  • README.md

Comment thread .github/workflows/run_sampler.yml
michieldegezelle and others added 2 commits August 4, 2026 16:29
Template names are directory names taken from the PR's own tree, so they
are untrusted text. Wrapping them in a single backtick pair let a name
containing a backtick close its code span and inject markdown into the
sampler's PR comment (CWE-116; spoofed links/formatting, not code
execution) — flagged by CodeRabbit on bso_github_actions#37.

Fence each name per CommonMark instead: one more backtick than the longest
run inside the name, plus a space pad when it starts or ends with one.
Names without backticks render exactly as before.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Template names are directory names from the PR's own tree. A name starting
with "-" is read by the CLI's option parser as a FLAG rather than a value:
commander stops consuming a variadic option (-h/-at take <names...>) at the
first "-"-prefixed token, so a directory named e.g. "--from-zip" would be
reinterpreted as an option instead of a template to sample. A leading "--"
separator does not protect variadic values, so the fix is an explicit
guard: fail the step with an actionable message (rename the directory)
before any CLI call.

Flagged by CodeRabbit as CWE-88 on lu_market#785. Names with internal or
trailing hyphens ("Cut-off", "Investment- and depreciation details") are
unaffected — only a leading "-" is rejected.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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.

1 participant