Skip to content

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

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#77
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: 38284f05-2cfe-4896-99e3-500a65d965e3

📥 Commits

Reviewing files that changed from the base of the PR and between 3034b06 and dc536ce.

📒 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. (18)
  • GitHub Check: scan / rust-secrets
  • GitHub Check: scan / gitleaks
  • GitHub Check: governance / Trusted-base reduction policy
  • GitHub Check: governance / Workflow security linter
  • GitHub Check: governance / Licence consistency
  • GitHub Check: governance / Guix primary / Nix fallback policy
  • GitHub Check: governance / Language / package anti-pattern policy
  • GitHub Check: scan / Hypatia Neurosymbolic Analysis
  • GitHub Check: rust-ci / Detect Cargo.toml
  • GitHub Check: analyze (actions, none)
  • GitHub Check: Validate A2ML manifests
  • GitHub Check: Validate K9 contracts
  • GitHub Check: Groove manifest check
  • GitHub Check: panic-attack assail
  • GitHub Check: Patch Bridge CVE triage
  • GitHub Check: Hypatia neurosymbolic scan
  • GitHub Check: Gitar
  • GitHub Check: Codacy Static Code Analysis
⚠️ CI failures not shown inline (6)

GitHub Actions: OpenSSF Compliance / 0_openssf-compliance.txt: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run SECFILE=""
 �[36;1mSECFILE=""�[0m
 �[36;1m[ -f "SECURITY.md" ] && SECFILE="SECURITY.md"�[0m
 �[36;1m[ -f "SECURITY.adoc" ] && SECFILE="SECURITY.adoc"�[0m
 �[36;1m[ -f ".github/SECURITY.md" ] && SECFILE=".github/SECURITY.md"�[0m
 �[36;1m�[0m
 �[36;1mif [ -z "$SECFILE" ]; then�[0m
 �[36;1m  echo "::error::SECURITY.md (or SECURITY.adoc) is required for OpenSSF Best Practices"�[0m

GitHub Actions: OpenSSF Compliance / openssf-compliance: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run SECFILE=""
 �[36;1mSECFILE=""�[0m
 �[36;1m[ -f "SECURITY.md" ] && SECFILE="SECURITY.md"�[0m
 �[36;1m[ -f "SECURITY.adoc" ] && SECFILE="SECURITY.adoc"�[0m
 �[36;1m[ -f ".github/SECURITY.md" ] && SECFILE=".github/SECURITY.md"�[0m
 �[36;1m�[0m
 �[36;1mif [ -z "$SECFILE" ]; then�[0m
 �[36;1m  echo "::error::SECURITY.md (or SECURITY.adoc) is required for OpenSSF Best Practices"�[0m

GitHub Actions: OpenSSF Compliance / openssf-compliance: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run if [ ! -f "LICENSE" ] && [ ! -f "LICENSE.txt" ] && [ ! -f "LICENSE.md" ]; then
 �[36;1mif [ ! -f "LICENSE" ] && [ ! -f "LICENSE.txt" ] && [ ! -f "LICENSE.md" ]; then�[0m
 �[36;1m  echo "::error::LICENSE file is required for OpenSSF Best Practices"�[0m

GitHub Actions: OpenSSF Compliance / openssf-compliance: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run if [ ! -f "CONTRIBUTING.md" ] && [ ! -f "CONTRIBUTING.adoc" ]; then
 �[36;1mif [ ! -f "CONTRIBUTING.md" ] && [ ! -f "CONTRIBUTING.adoc" ]; then�[0m
 �[36;1m  echo "::error::CONTRIBUTING file is required for OpenSSF Best Practices"�[0m

GitHub Actions: OpenSSF Compliance / openssf-compliance: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run if [ ! -f "README.md" ] && [ ! -f "README.adoc" ] && [ ! -f "README.rst" ] && [ ! -f "README.txt" ] && [ ! -f "README" ]; then
 �[36;1mif [ ! -f "README.md" ] && [ ! -f "README.adoc" ] && [ ! -f "README.rst" ] && [ ! -f "README.txt" ] && [ ! -f "README" ]; then�[0m
 �[36;1m  echo "::error::README file is required for OpenSSF Best Practices"�[0m

GitHub Actions: OpenSSF Compliance / openssf-compliance: fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op

Conclusion: failure

View job details

##[group]Run if [ ! -d ".machine_readable" ]; then
 �[36;1mif [ ! -d ".machine_readable" ]; then�[0m
 �[36;1m  echo "::error::.machine_readable/ directory is required"�[0m
🔇 Additional comments (1)
tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed end-to-end template instantiation tests so placeholder replacement processes each matched file correctly.

Walkthrough

The end-to-end template instantiation test now passes each matched file path directly to the embedded Bash script through the find -exec argument list.

Changes

Template instantiation test

Layer / File(s) Summary
Pass matched paths to Bash
tests/e2e/template_instantiation_test.sh
The find -exec command uses {} to provide each matched pathname as the embedded Bash script’s file argument.

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

Merge Risk: ⚪ Minimal · up to dc536

This localized test change fixes the placeholder replacement command, and no actionable merge-blocking risk remains after normal checks and review.

Poem

A rabbit checks each file in line
The path now lands in Bash just fine
find sends the name along
The test runs where it belongs
One small fix makes the trail align

🚥 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 correction. However, it does not follow the repository template because it omits the required Summary, Changes, RSR Quality Checklist, Testing,… Restructure the description to use the repository template. Add the Summary, Changes, RSR Quality Checklist, and Testing sections, and complete the applicable checklist items. Add Screenshots or terminal output if applicable.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the test fix and the corrected find -exec behaviour. It is specific and related to the main change.
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 correction. However, it does not follow the repository template because it 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.

@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 correctly identifies and fixes the syntax error in the find -exec command (adding the terminator and placeholder), the implementation of the subshell script introduces new logic errors that prevent the placeholders from being replaced. Specifically, the script references an uninitialized variable $file and relies on parent-shell variables within a single-quoted string where they cannot expand. Although Codacy reports the PR is up to standards, these logic flaws represent a significant gap in the acceptance criteria. The test likely still fails to perform actual template instantiation.

About this PR

  • The pattern of using sh -c '...' with single quotes prevents the expansion of variables like $placeholder and $value from the parent shell. These must be either exported or passed as additional positional arguments to the subshell to ensure the sed command behaves as expected.

Test suggestions

  • Template instantiation test correctly identifies files and replaces placeholders

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 sh -c command string uses the variable "$file", but the filename from find is passed as a positional argument ($1). Inside the subshell, "$file" will be empty. Additionally, because the script block is single-quoted, shell variables like $placeholder and $value will not expand.

Update the command to assign the file path (e.g., file="$1") and ensure all variables are correctly scoped or passed into the subshell. Try this prompt in your IDE agent:

In tests/e2e/template_instantiation_test.sh, update the find -exec block to correctly assign file="$1" and ensure $placeholder and $value are accessible inside the subshell script.

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