Skip to content

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

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/find-exec-terminator
Aug 28, 2026
Merged

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op#67
hyperpolymath merged 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: 17600dbd-9282-45ec-a314-2740f82f4706

📥 Commits

Reviewing files that changed from the base of the PR and between 18719b7 and 7603597.

📒 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. (10)
  • GitHub Check: analyze (actions, none)
  • GitHub Check: scan / Hypatia Neurosymbolic Analysis
  • GitHub Check: governance / Guix primary / Nix fallback policy
  • GitHub Check: governance / Trusted-base reduction policy
  • GitHub Check: governance / Check Workflow Staleness
  • GitHub Check: governance / Language / package anti-pattern policy
  • GitHub Check: Hypatia neurosymbolic scan
  • GitHub Check: E2E — FFI build, ABI correspondence, grammar smoke
  • GitHub Check: FFI — Zig unit tests
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed template instantiation so placeholders are correctly replaced in every matched file during end-to-end testing.

Walkthrough

The end-to-end template test now passes each matched file from find to the placeholder replacement command.

Changes

Template instantiation test

Layer / File(s) Summary
Pass matched files to replacement command
tests/e2e/template_instantiation_test.sh
The find -exec command passes each matched file through {} instead of the literal "$file" argument.

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

Merge Risk: ⚪ Minimal · up to 76035

This is a localized test-script correction, and no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checked each file in line
find now passes the path in time
The placeholders change with care
No literal variable lingers there
The test hops on, precise and fine

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description clearly explains the defect, its consequence, and the correction. However, it does not use the required template sections and does not provide the required checklist status or testing … Update the description to include the ## Summary, ## Changes, ## RSR Quality Checklist, ## Testing, and ## Screenshots sections. Mark the applicable checklist items and describe the tests that were run, or state why a section does…
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the test fix: it terminates the find -exec command 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 clearly explains the defect, its consequence, and the correction. However, it does not use the required template sections and does not provide the required checklist status or testing details.

Resolution

Update the description to include the ## Summary, ## Changes, ## RSR Quality Checklist, ## Testing, and ## Screenshots sections. Mark the applicable checklist items and describe the tests that were run, or state why a section does not apply.

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
📝 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

The PR correctly identifies a syntax error in the 'find' command terminator, but the current implementation contains logic flaws that will prevent the template instantiation from working. Specifically, using single quotes for the subshell prevents the expansion of $placeholder and $value, and the configuration variables are not exported to the subshell's environment. While Codacy reports that the code is up to standards, these functional gaps will result in a no-op or failure during actual execution.

Key issues to address before merging:

  1. Fix shell variable expansion inside the 'find -exec' subshell.
  2. Export or pass configuration variables to the subshell to ensure template tokens are replaced.

About this PR

  • Systemic issue with subshell environment: Several configuration variables (TEST_OWNER, TEST_FORGE, etc.) are defined but not available to the logic inside the 'find -exec' subshell. Consider a more robust way to pass environment context to subshells.
1 comment outside of the diff
tests/e2e/template_instantiation_test.sh

line 21-32 🟡 MEDIUM RISK
These configuration variables appear unused because they are not used in the parent shell scope. If they are intended to be used inside the 'find -exec sh -c' subshell to perform template replacements, they must be exported to the environment.

Try running the following prompt in your IDE agent:

Check if TEST_OWNER, TEST_FORGE, TEST_AUTHOR_EMAIL, TEST_DESCRIPTION, TEST_PRIMARY_LANGUAGE, and YELLOW are used within the find -exec subshell. If so, add 'export' before their definitions at the top of the script so they are available to the subshell.

Test suggestions

  • Verify that 'template_instantiation_test.sh' successfully replaces template tokens (e.g., {{project}}) in generated source files.
  • Verify that the 'find' command correctly iterates over files and does not exit with a syntax error (SC2067).

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 variables $placeholder and $value are inside a single-quoted string, meaning the parent shell will not expand them. Additionally, using -exec ... {} \; runs the command once per file, making the internal for file in "$@" loop redundant.

Try running the following prompt in your coding agent:

In tests/e2e/template_instantiation_test.sh, modify the find command to pass $placeholder and $value as the first two arguments to the sh -c script, shift 2 inside the script to clear them from the positional parameters, and change the terminator to {} + so the for loop can efficiently process all files.

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