Skip to content

fix(codegen): emit no-op in teardown when every step is skipped#190

Merged
MattDevy merged 4 commits into
mainfrom
fix/codegen-invalid-bash
Apr 17, 2026
Merged

fix(codegen): emit no-op in teardown when every step is skipped#190
MattDevy merged 4 commits into
mainfrom
fix/codegen-invalid-bash

Conversation

@MattDevy
Copy link
Copy Markdown
Contributor

Summary

  • Fixes the five syntax error near unexpected token '}' failures in the ES functional matrix. When every teardown step maps to an unregistered CLI action (# SKIPPED: action "..." not registered), the generated teardown() body contained only comments — bash rejects a comment-only function body with that error.
  • generator.ts now detects the all-comments case and appends a : no-op so the function body is syntactically valid.
  • Added skipped-teardown.yml fixture plus two generator tests: one asserts the no-op is present, the other pipes the generated script through bash -n to guarantee it parses.

Closes #188.

Scripts previously failing, now syntactically valid

  • test/functional/es/indices/data_stream_mappings.sh
  • test/functional/es/indices/data_streams_options.sh
  • test/functional/es/indices/migrate_modify_data_stream.sh
  • test/functional/es/machine_learning/buckets_serverless.sh
  • test/functional/es/query_rules/30_test.sh

Verified locally with bash -n against all 78 regenerated scripts — zero failures.

Stack

Based on #187. Merge that first, this second.

Test plan

  • npm run test:unit green (hasExecutableLine helper + bash -n round-trip test)
  • Buildkite ES matrix no longer shows the five syntax errors
  • Other generated scripts still behave as before (no regression in the 73 scripts that were already passing bash parsing)

Buildkite GCP agents don't ship nvm, so `nvm install` failed with
`command not found`. Move the Node setup into a repository
pre-command hook that auto-installs nvm when missing and runs
before every step automatically when NODE_VERSION is set.
The generated ES test scripts invoke `elastic` as a global command
(per README dev setup). CI was missing `npm link`, causing every
script to fail with `elastic: command not found`.
Bash requires a function body to contain at least one executable
statement. When every teardown step maps to an unregistered CLI
action, the generator produced a `teardown() { # SKIPPED ... }`
body that was comments-only, failing with
`syntax error near unexpected token '}'` on startup.

Detect the all-comments case and append `:` so the function is
syntactically valid. Added a fixture (skipped-teardown.yml) and two
tests: one asserts the no-op is present, and one pipes the generated
script through `bash -n` to guarantee it parses.

Closes #188
@MattDevy MattDevy requested a review from margaretjgu April 17, 2026 14:30
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 17, 2026

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 2.73s
✅ REPOSITORY gitleaks yes no no 8.49s
✅ REPOSITORY git_diff yes no no 0.07s
✅ REPOSITORY secretlint yes no no 2.02s
✅ REPOSITORY trivy yes no no 13.79s
✅ TYPESCRIPT eslint 2 0 0 2.65s

See detailed reports in MegaLinter artifacts
Set VALIDATE_ALL_CODEBASE: true in mega-linter.yml to validate all sources, not only the diff

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

Base automatically changed from claude/dreamy-khayyam-c2e0ed to main April 17, 2026 14:41
@MattDevy MattDevy merged commit 9245d80 into main Apr 17, 2026
19 of 20 checks passed
@MattDevy MattDevy deleted the fix/codegen-invalid-bash branch April 17, 2026 14:50
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.

codegen: generated ES functional scripts emit invalid bash (syntax error near '}')

1 participant