Skip to content

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

Merged
hyperpolymath merged 2 commits into
mainfrom
fix/find-exec-terminator
Aug 28, 2026
Merged

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op#64
hyperpolymath merged 2 commits 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: 1bc1e359-0752-44e4-9510-dc58a2046eda

📥 Commits

Reviewing files that changed from the base of the PR and between 390ed0d and 1983f9c.

📒 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
🔇 Additional comments (2)
tests/e2e/template_instantiation_test.sh (2)

115-116: LGTM!


142-142: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved template instantiation testing to ensure placeholder replacement is applied correctly to each matched file.

Walkthrough

The end-to-end template instantiation test exports placeholder values for the nested Bash process and passes each matched file directly to the replacement command.

Changes

Template instantiation test

Layer / File(s) Summary
Placeholder replacement inputs
tests/e2e/template_instantiation_test.sh
The test exports placeholder values for the nested Bash process. The find -exec command uses {} to pass each matched file instead of $file.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 1983f

This localized test-script fix corrects the file-replacement command without introducing an actionable merge-blocking risk; it is merge-ready after normal checks and review.

Poem

I’m a rabbit in the test-file lane
Exported values hop on the train
{} carries each path
Bash completes the task
Templates bloom again

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the defect, its impact, and the correction. However, it does not follow the repository template because it omits the required section headings, the RSR Quality Checkli… Restructure the description using the repository template. Add Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sections as applicable. Mark the checklist items accurately and state which tests or validation commands were r…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: it terminates the find -exec command and passes {} instead of the incorrect variable.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
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 clearly explains the defect, its impact, and the correction. However, it does not follow the repository template because it omits the required section headings, the RSR Quality Checklist, and a dedicated Testing section.

Resolution

Restructure the description using the repository template. Add Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sections as applicable. Mark the checklist items accurately and state which tests or validation commands were run.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 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.

@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

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 26, 2026
@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 the syntax errors in the find -exec command have been addressed, the PR fails to achieve its functional goal. The subshell script uses a single-quoted string, which prevents it from accessing the $file variable from the parent shell. Consequently, the sed command operates on an empty filename, and the placeholder replacement remains a no-op. Despite Codacy indicating the PR is 'up to standards', this logic error must be fixed to ensure the test suite actually validates template instantiation.

Test suggestions

  • Verify that 'template_instantiation_test.sh' correctly replaces placeholders in a generated template structure.

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 find -exec syntax is now correct, but the subshell logic remains broken. The subshell receives the file path from find as $1, but the script uses "$file". Since the subshell script is single-quoted, it does not have access to the outer shell's $file variable. To fix this, use "$1" directly in the sed command or assign file="$1" at the start of the command string (e.g., sh -c 'file="$1"; sed -i ...').

@hyperpolymath
hyperpolymath enabled auto-merge (squash) August 28, 2026 07:45
@sonarqubecloud

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath merged commit 0369635 into main Aug 28, 2026
20 checks passed
@hyperpolymath
hyperpolymath deleted the fix/find-exec-terminator branch August 28, 2026 16:16
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