Skip to content

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

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#48
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.
@sonarqubecloud

Copy link
Copy Markdown

@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: cd54483c-3120-4e5b-bae9-de59b9e806fe

📥 Commits

Reviewing files that changed from the base of the PR and between f6f6aa9 and 1a74479.

📒 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. (12)
  • GitHub Check: rust-ci / Cargo check + clippy + fmt
  • GitHub Check: analyze (actions, none)
  • GitHub Check: Hypatia neurosymbolic scan
  • GitHub Check: Patch Bridge CVE triage
  • GitHub Check: SonarQube
  • GitHub Check: Empty-linter (invisible characters)
  • GitHub Check: Groove manifest check
  • GitHub Check: docs
  • GitHub Check: lint
  • GitHub Check: openssf-compliance
  • 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 tests so discovered files are processed correctly.
    • Corrected the command termination used during placeholder replacement.

Walkthrough

The end-to-end template instantiation test now passes each discovered file to its embedded Bash replacement script and uses the correct find -exec terminator.

Changes

Template instantiation testing

Layer / File(s) Summary
Placeholder replacement command
tests/e2e/template_instantiation_test.sh
The find -exec command passes each matched file with {} and terminates with \;.

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

Merge Risk: ⚪ Minimal · up to 1a744

This is a localized test-script fix with no actionable merge-blocking risk remaining after normal checks and review.

Poem

A rabbit checks each file in line
The placeholders now align
Braces pass the paths with care
The command ends clean and fair
Tests hop onward, neat and fine

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defect, impact, and intended fix, but it does not follow the required template. It omits the required section headings, checklist status, testing details, and applicable s… Rewrite the description using the repository template. Complete the Summary, Changes, RSR Quality Checklist, and Testing sections. Add Screenshots or terminal output if applicable, and state which checks were run and their results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: fixing the find -exec terminator and passing {} to the command.
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, impact, and intended fix, but it does not follow the required template. It omits the required section headings, checklist status, testing details, and applicable screenshots or terminal output.

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.

@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 resolves the immediate syntax error that rendered the find command a no-op, the template substitution logic remains non-functional. Findings indicate that shell variables are not correctly expanded inside the subshell, meaning the E2E test likely still fails to perform actual replacements. Additionally, there are maintenance concerns regarding the duplication of this script across multiple repositories and unused configuration variables.

1 comment outside of the diff
tests/e2e/template_instantiation_test.sh

line 21 🟡 MEDIUM RISK
The variable TEST_OWNER is defined but never referenced. If it is intended for template configuration, ensure it is utilized in the substitution logic; otherwise, it should be removed.

Test suggestions

  • Verify that template placeholders (e.g., {{project}}) are actually replaced in the generated files during the E2E test.
Low confidence findings
  • This file is a stale duplicate of a script existing in 30 other repositories. Relying on manual updates in this repository rather than a centralized template upstream creates a maintenance burden and risk of configuration drift.

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

Comment on lines 137 to +140
sed -i "s|$placeholder|$value|g" "$file"
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 substitution logic is still a no-op. Because the subshell string is single-quoted, the parent shell's $placeholder and $value variables are not expanded. Within the subshell, you must use "$1" to refer to the file path passed by find, as $file is undefined. Recommendation: Pass the variables as arguments to the subshell (e.g., sh -c '...' _ "$placeholder" "$value" "{}") or use double quotes with appropriate escaping. Additionally, using '+' instead of ';' would be more efficient for large file sets.

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