Skip to content

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

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

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: d90ef675-f657-4c46-9b9f-363c9d51bfe1

📥 Commits

Reviewing files that changed from the base of the PR and between 117a1a2 and 29c1cf6.

📒 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)

142-142: Confirm that the embedded command uses the matched path.

{} passes each matched path to bash -c as $1; it does not define $file. Confirm that the script assigns file="$1" or uses $1 for every replacement operation. Otherwise, the replacement can still target an empty path.

#!/usr/bin/env bash
set -euo pipefail

path="tests/e2e/template_instantiation_test.sh"
body="$(sed -n '130,145p' "$path")"
printf '%s\n' "$body"

if printf '%s\n' "$body" | rg -q '\$file' &&
   ! printf '%s\n' "$body" | rg -q 'file[[:space:]]*=[[:space:]]*"\$1"|\$1'; then
  echo 'The embedded command references $file without a visible $1 hand-off.'
  exit 1
fi

115-116: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Improved placeholder replacement during template setup by ensuring the correct file path is supplied, helping generated files update reliably.

Walkthrough

The template instantiation end-to-end test now exports placeholder-replacement settings and passes each matched file path to the embedded Bash command.

Changes

Template instantiation test

Layer / File(s) Summary
Pass matched file path to replacement command
tests/e2e/template_instantiation_test.sh
The test exports the replacement settings. The find -exec bash -c invocation passes each matched file path as the positional argument.

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

Merge Risk: 🔵 Low · up to 29c1c

The change is localized and intended to make each matched file reach the replacement command, but merge readiness still depends on confirming that the embedded command consumes the matched path through $1; otherwise replacements could still target an empty path. This is a bounded correctness follow-up and is otherwise mergeable with owner awareness.

Poem

A rabbit checked the file path bright
The Bash command now gets it right
Settings cross the process gate
Each matched file arrives in state
The test runs cleanly tonight

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the defects, impact, and correction, but it does not follow the required template. It omits the required Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sect… Restructure the description using the repository template. Add the required headings, list the key changes, complete the applicable checklist items, and state the tests that were run with their results.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: fixing the find -exec terminator and passing {} so placeholder replacement runs.
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 explains the defects, impact, and correction, but it does not follow the required template. It omits the required Summary, Changes, RSR Quality Checklist, Testing, and Screenshots sections.

  • 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

The PR attempts to fix a non-functional placeholder replacement step in the E2E tests by correcting the syntax of the find -exec command. However, the current implementation is still non-functional because the subshell invoked by sh -c does not correctly map the passed file path to the $file variable used in the script block. This results in the sed command operating on an empty variable.

While Codacy reports that the PR is up to standards, this automated check does not detect the runtime logic error in the shell script. Furthermore, the fix lacks a corresponding test case to verify that placeholders are now being replaced as intended. Addressing the scoping issue is critical to ensuring the E2E tests provide the intended coverage.

About this PR

  • There is no new test case or verification step included in this PR to prove that the placeholder replacement now functions as expected. Relying solely on the code change without verifying the output in the E2E environment leaves the fix unvalidated.
  • This stale or broken code exists in 30 other repositories. Given the systemic nature of this issue, consider whether this test utility should be centralized or if a coordinated update across all affected repositories is planned to prevent logic drift.

Test suggestions

  • Verify that template placeholders (e.g., {{project}}) are correctly replaced in generated files during the E2E test run.
  • Verify that the find -exec command executes without ShellCheck SC2067 errors or syntax failures.
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Verify that template placeholders (e.g., {{project}}) are correctly replaced in generated files during the E2E test run.
2. Verify that the `find -exec` command executes without ShellCheck SC2067 errors or syntax failures.

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 variable "$file" inside the subshell is undefined. Since find now passes the filename via {}, you should assign it at the start of the script block (e.g., sh -c 'file="$1"; ...') or use "$1" directly in the sed command. Try updating the sh -c command string to assign file="$1" at the beginning of the script so that the subsequent sed command uses the path provided by find.

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

Copy link
Copy Markdown

@github-actions

Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 37 issues detected

Severity Count
🔴 Critical 6
🟠 High 20
🟡 Medium 11

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in label-triage.yml",
    "type": "missing_timeout_minutes",
    "file": "label-triage.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in labels.yml",
    "type": "missing_timeout_minutes",
    "file": "labels.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Issue in push-email-notify.yml",
    "type": "missing_timeout_minutes",
    "file": "push-email-notify.yml",
    "action": "flag",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "6 workflow(s) with tag-pinned (not SHA-pinned) actions in lucidscript",
    "type": "DependencyPinning",
    "file": "/home/runner/work/lucidscript/lucidscript",
    "action": "auto_fix",
    "rule_module": "scorecard",
    "severity": "medium",
    "remediation": "Pin GitHub Actions and Docker base images by SHA hash.",
    "scorecard_check": "Pinned-Dependencies"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/workflow_audit/missing_timeout_minutes -- Hypatia workflow_audit: missing_timeout_minutes -- 1 day(s) old",
    "type": "CSA001",
    "file": "labels.yml",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/workflow_audit/missing_timeout_minutes -- Hypatia workflow_audit: missing_timeout_minutes -- 1 day(s) old",
    "type": "CSA001",
    "file": "label-triage.yml",
    "action": "review",
    "rule_module": "code_scanning_alerts",
    "severity": "medium"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 1 day(s) old",
    "type": "CSA001",
    "file": ".machine_readable/6a2/PLAYBOOK.a2ml",
    "action": "update",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 1 day(s) old",
    "type": "CSA001",
    "file": ".machine_readable/6a2/NEUROSYM.a2ml",
    "action": "update",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 1 day(s) old",
    "type": "CSA001",
    "file": ".machine_readable/6a2/AGENTIC.a2ml",
    "action": "update",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  },
  {
    "reason": "Code scanning (Hypatia): hypatia/structural_drift/SD004 -- Hypatia structural_drift: SD004 -- 1 day(s) old",
    "type": "CSA001",
    "file": ".machine_readable/6a2/ECOSYSTEM.a2ml",
    "action": "update",
    "rule_module": "code_scanning_alerts",
    "severity": "high"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

@hyperpolymath
hyperpolymath merged commit b9f298c into main Aug 28, 2026
10 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