fix: correct sed delimiter in GH_REPO_URL extraction (#63)#64
Merged
Conversation
buildReusableUserData()'s per-boot registerScript extracted GH_REPO_URL with sed using "#" as the delimiter, while GH_TOKEN and GH_LABEL used "/". Because the pattern ends in the sed end-of-line anchor "$" immediately followed by "#", and the whole sed argument sits inside a double-quoted shell string, bash expands "$#" (number of positional arguments, always 0 for this script) before sed ever runs. That corrupts the sed script and makes it error out with "unterminated 's' command". Since the assignment isn't guarded with `|| true` and the script runs under `set -euo pipefail`, the failure aborted the whole registerScript at the "configuring" phone-home step, so every `reuse: stop` warm-pool launch failed registration before config.sh was ever invoked. Switch the delimiter to "," which isn't a bash special-parameter suffix, matching the fix verified in the issue against both BSD and GNU sed. Adds a regression test that extracts the real GH_REPO_URL sed line out of the generated user-data and executes it in bash, so it fails against the old "#" delimiter and passes with the fix. Fixes #63 Signed-off-by: kurok <22548029+kurok@users.noreply.github.com>
kurok
added a commit
to namecheap/terraform-provider-namecheap
that referenced
this pull request
Jul 6, 2026
The previous re-pin (aa10310) got us the #62 phone-home fix, which then revealed the real blocker: buildReusableUserData()'s GH_REPO_URL extraction used '#' as its sed delimiter, but '$#' inside the double-quoted sed script is bash's positional-argument-count special parameter, which silently corrupts the pattern before sed ever sees it (confirmed via bash -x tracing and reproduced against both BSD and GNU sed). Every reuse:stop registration failed at the configuring step as a result. Fixed upstream in namecheap/ec2-github-runner#64 (fixes #63), merged as 301e1c1, v4.0.0 moved to match. Re-pinning this PR's 4 usages to that commit. Signed-off-by: kurok <22548029+kurok@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #63.
buildReusableUserData()'s per-bootregisterScriptextractedGH_REPO_URLwithsedusing#as the delimiter, while theGH_TOKENandGH_LABELextraction lines directly above it correctly use/. Because the sed pattern ends in the end-of-line anchor$immediately followed by the#delimiter, and the whole sed argument sits inside a double-quoted shell string, bash expands$#(the special "number of positional arguments" parameter, always0for this script) before sed ever sees it. That corrupts the sed script intos#^GH_REPO_URL='\(.*\)'0\1#p, which errors withunterminated 's' command.Since this is a plain
GH_REPO_URL=$(...)assignment underset -euo pipefail(no|| trueguard), the sed failure aborts the wholeregisterScriptat theconfiguringphone-home step — beforeconfig.shis ever invoked. This is a 100% reproducible failure for everyreuse: stopwarm-pool launch.Fix
Swap the delimiter to
,, which isn't a bash special-parameter suffix when preceded by$:Verified against both BSD sed (macOS) and GNU sed semantics — this mirrors the exact root cause and fix from the issue writeup.
Test plan
tests/warmpool.test.jsthat extracts the actualGH_REPO_URL=$(... sed ...)line out of the real generated user-data (not a reimplementation) and executes it inbashwith a controlled fake IMDS user-data value.#-delimiter line (sed: unescaped newline inside substitute pattern, command exits non-zero underset -e).https://github.com/foo/barcorrectly).npm test— 227/227 passing (226 pre-existing + 1 new).npm run lint— clean.npm run package— rebuiltdist/index.js; confirmed the rebuild is deterministic (byte-identical across two consecutive runs) and the diff is scoped to the single fixed line.