Skip to content

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op - #55

Open
hyperpolymath wants to merge 1 commit into
mainfrom
fix/find-exec-terminator
Open

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op#55
hyperpolymath wants to merge 1 commit into
mainfrom
fix/find-exec-terminator

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

tests/e2e/template_instantiation_test.sh ran find … -exec bash -c '…' _ "\$file", which has two defects on one line:

  1. No ; or + terminator — the file does not parse (SC2067).
  2. "\$file" where {} belongs\$file is assigned only inside the -exec body, so in the outer scope it is unset. \$1 arrived empty, file="", and every grep/sed operated on an empty path.

The consequence is worse than a lint error. The placeholder-replacement step silently did nothing, then logged "All placeholder tokens replaced". A test whose entire purpose is to prove instantiation worked was passing without replacing a single token — a plausible cause of estate repos shipping with literal {{project}} still in their sources.

Corrected to ' _ {} \; so find passes each matched path.

Found by an estate-wide sweep of 5,111 scripts across 375 repos: this identical stale copy exists in 30 repositories. rsr-template-repo's own copy is already correct and restructured (371 lines vs the 268 here), so these are stale duplicates that never picked up the upstream fix.

…as a no-op

tests/e2e/template_instantiation_test.sh ran:

    find ... -exec bash -c '
        file="$1"
        ... grep/sed over $file ...
    ' _ "$file"

Two defects in that one line:

  1. No ';' or '+' terminator, so the file does not parse (SC2067).
  2. "$file" is passed where {} belongs. $file is assigned ONLY inside the
     -exec body, so in the outer scope it is UNSET — $1 arrived empty, file=""
     and every grep/sed operated on an empty path.

⚠ The consequence is worse than a lint error: the placeholder-replacement step
SILENTLY DID NOTHING, then logged "All placeholder tokens replaced". A test
whose whole purpose is to prove instantiation worked was passing without
replacing a single token. That is a plausible cause of estate repos shipping
with literal {{project}} tokens still in their sources.

Corrected to "' _ {} \;" so find passes each matched path.

Found by an estate-wide shellcheck sweep of 5,111 scripts across 375 repos:
this identical stale copy exists in 30 repositories. rsr-template-repo's own
copy is already correct and restructured (371 lines vs the 268 here), so these
are stale duplicates that never picked up the upstream fix.
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 30e250b3-9941-475a-9c31-fae7441d99ff

📥 Commits

Reviewing files that changed from the base of the PR and between 595dcaf and 25fffbc.

📒 Files selected for processing (1)
  • tests/e2e/template_instantiation_test.sh

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.

📜 Recent review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: Deposit findings for gitbot-fleet
  • GitHub Check: rust-ci / Detect Cargo.toml
  • GitHub Check: analyze (javascript-typescript, none)
  • GitHub Check: Empty-linter (invisible characters)
  • GitHub Check: Validate K9 contracts
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Gitar
🔇 Additional comments (1)
tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed template instantiation so placeholder tokens are correctly replaced in every matching file.
    • Resolved an issue that prevented the replacement process from receiving and processing discovered files.

Walkthrough

The end-to-end template test now passes each file found by find to the placeholder replacement script. This replaces the undefined outer-shell variable with find’s {} argument.

Changes

Template instantiation test

Layer / File(s) Summary
Pass matched files to replacement script
tests/e2e/template_instantiation_test.sh
The find -exec bash -c command now processes each matched file with the {} placeholder and \; terminator.

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

Merge Risk: ⚪ Minimal · up to 25fff

This is a localized test-script correction that restores the intended placeholder replacement behavior; no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit found a file in flight
And passed it through the script just right
The tokens hop, the test runs clean
No empty path is left unseen
One tiny fix completes the scene

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defect, its impact, and the fix. However, it does not follow the repository template and omits the required Summary, Changes, RSR Quality Checklist, Testing, and Screensho… Restructure the description using the repository template. Add the required sections, complete the applicable RSR checklist items, and document the tests that were run.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: it fixes the find -exec terminator and passes {} so placeholder replacement runs.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1…
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.
Full details: Description check

Explanation

The description explains the defect, its impact, and the fix. However, it does not follow the repository template and omits the required Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sections.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 1 files.

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

Copy link
Copy Markdown

@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Important

You are using the Gitar free plan. Upgrade to unlock code review, CI analysis, auto-apply, custom automations, and more.

Gitar

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production 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.

Pull Request Overview

While this PR addresses the syntax errors in the find command by adding the required terminator and placeholder, the implementation remains logically flawed. The test script is still a no-op because the variables $placeholder, $value, and $file are used within a single-quoted subshell (sh -c), which prevents the parent shell from expanding them.

Furthermore, there is a gap in meeting the acceptance criteria: although the filename is passed via {}, it is not assigned to the $file variable inside the subshell. These issues should prevent merging as the template instantiation test will continue to fail or do nothing despite the syntax fix.

About this PR

  • The changes resolve the shell syntax error (missing terminator) but do not address the variable isolation issue. The test remains non-functional because the subshell cannot access the necessary context to perform replacements.

Test suggestions

  • Verify the find -exec command executes without syntax errors (SC2067).
  • Confirm that sed replacement logic within the find subshell correctly modifies the target files.

TIP Improve review quality by adding custom instructions
TIP How was this review? Give us feedback

fi
done
' _ "$file"
' _ {} \;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔴 HIGH RISK

The script block uses variables like "$file", "$placeholder", and "$value" which are not expanded by the outer shell because of the single quotes. While the filename is now passed as {} (which becomes $1 in the subshell), it is not assigned to the 'file' variable used by the sed command. This will cause the command to fail or do nothing as the variables will be empty in the subshell. To fix this, you must either use double quotes (carefully) or pass the variables as additional arguments to the subshell and assign them internally (e.g., sh -c 'file=$1; placeholder=$2; ...' -- "{}" "$placeholder").

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