Skip to content

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

Open
hyperpolymath wants to merge 2 commits into
mainfrom
fix/find-exec-terminator
Open

fix(tests): terminate find -exec and pass {} — the placeholder step was a no-op#192
hyperpolymath wants to merge 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.
@gitar-bot

gitar-bot Bot commented Aug 26, 2026

Copy link
Copy Markdown

Gitar is working

Gitar

@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

Next included review available in 43 minutes.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 9d96c8f5-a1fd-4d0e-9241-27054af4f180

📥 Commits

Reviewing files that changed from the base of the PR and between fb96b3d and 8a16106.

📒 Files selected for processing (1)
  • affinescript-ecosystem/rattlescript/tests/e2e/template_instantiation_test.sh

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: 7c99cd3b-41f4-4c56-9f43-c4608ad0e9ce

📥 Commits

Reviewing files that changed from the base of the PR and between 1642050 and fb96b3d.

📒 Files selected for processing (1)
  • affinescript-ecosystem/rattlescript/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. (3)
  • GitHub Check: governance / Validate Hypatia Baseline
  • GitHub Check: hypatia / Hypatia Neurosymbolic Analysis
  • GitHub Check: Codacy Static Code Analysis
🔇 Additional comments (1)
affinescript-ecosystem/rattlescript/tests/e2e/template_instantiation_test.sh (1)

140-140: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Tests
    • Improved the template instantiation end-to-end test so placeholder replacement is applied reliably to every matched file.

Walkthrough

The template instantiation end-to-end test now passes each matched file to the inline shell script as $1 during placeholder replacement.

Changes

Template instantiation testing

Layer / File(s) Summary
Pass matched files to replacement script
affinescript-ecosystem/rattlescript/tests/e2e/template_instantiation_test.sh
The find -exec bash -c command now uses the standard ' _ {} \; argument form. Each matched file is available as $1.

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

Merge Risk: ⚪ Minimal · up to fb96b

This corrects the test’s file replacement command so matched paths are passed and processed; no actionable merge-blocking risk remains beyond normal checks and review.

Poem

A rabbit checks each file in line
$1 now holds the path just fine
The placeholders change as planned
With safer arguments close at hand
The test hops onward, neat and grand

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the test fix and states that the find -exec command now terminates and passes the {} placeholder.
Description check ✅ Passed The description directly explains the defects in the find -exec invocation, their test impact, and the corrected 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: 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.

✨ 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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Aug 26, 2026
@codacy-production

Copy link
Copy Markdown
Contributor

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
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

Although this PR correctly fixes the find -exec termination syntax to resolve the immediate shell error, the resulting implementation remains non-functional (a 'no-op') due to how variables are handled in the subshell. Specifically, shell variables $placeholder and $value will not expand inside the single-quoted subshell, and the file path passed via {} is not correctly mapped to the $file variable.

Furthermore, the sed command lacks portability for macOS/BSD environments and does not safely handle special characters like | or &. While Codacy indicates the PR is 'up to standards' based on static analysis, the functional logic errors identified in the review represent a high risk of failure in the test suite. Additionally, the file is noted to be significantly behind its upstream reference, which may lead to further divergence issues.

Test suggestions

  • Verify find -exec correctly iterates over template files and executes the subshell logic.
  • Verify the bash subshell correctly maps the passed {} path to the variable used in sed commands.
Low confidence findings
  • This script is currently a 'stale copy' (268 lines) compared to the upstream reference (371 lines). While this PR fixes a syntax bug, the divergence suggests the file may require a full synchronization to prevent missing other critical logic or modern standards present in the upstream version.

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
Contributor

Choose a reason for hiding this comment

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

🔴 HIGH RISK

The find syntax is now valid, but the subshell logic (lines 137-140) remains broken for several reasons:

  1. Variable Scoping: Because the sh -c command is wrapped in single quotes, $placeholder and $value are not expanded by the parent shell and will be empty in the subshell.
  2. Path Mapping: The path passed via {} becomes $1 in the subshell, but the script attempts to use $file, which is undefined.
  3. Sed Portability & Safety: The sed -i command is not portable to macOS/BSD (which requires sed -i '') and will fail if $value contains delimiters like | or the special character &.

Recommendation: Refactor the command to pass variables as positional arguments:
find ... -exec sh -c 'p="$1"; v="$2"; shift 2; for f in "$@"; do sed -i "s|$p|$v|g" "$f"; done' _ "$placeholder" "$value" {} +

@hyperpolymath
hyperpolymath enabled auto-merge (squash) August 28, 2026 07:47
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