Skip to content

fix: extract seed-local-community Python/SQL so it parses under bash 3.2#1362

Open
cameronhotchkies wants to merge 1 commit into
block:mainfrom
cameronhotchkies:fix/seed-hosts-bash32-portability
Open

fix: extract seed-local-community Python/SQL so it parses under bash 3.2#1362
cameronhotchkies wants to merge 1 commit into
block:mainfrom
cameronhotchkies:fix/seed-hosts-bash32-portability

Conversation

@cameronhotchkies

Copy link
Copy Markdown

scripts/seed-local-community.sh inlined its host-derivation Python as a heredoc inside $(...) command substitution. Stock macOS /bin/bash (3.2) does not treat a heredoc body as literal there, so quotes/apostrophes in the Python flip its quote state and the whole script fails to parse (unexpected EOF while looking for matching "). That breaks just relay / just setup (via the _ensure-migrations recipe) on a default macOS toolchain — no modern bash on PATH.

Fix: split the logic out so the shell never parses Python or SQL source.

  • scripts/seed-hosts.py — host derivation (unchanged logic)
  • scripts/seed-communities.sql — the upsert, taking the host list via a :hosts psql var
  • seed-local-community.sh — now only wires them together

Seeded loopback authorities are identical to before.

Verified locally: parses under /bin/bash 3.2; just _ensure-migrations green; both idempotent (INSERT 0 0) and insert (INSERT 0 1) paths exercised.

🤖 Generated with Claude Code

seed-local-community.sh inlined its host-derivation Python as a heredoc
inside $(...) command substitution. Stock macOS /bin/bash (3.2) does not
treat a heredoc body as literal there, so quotes/apostrophes in the Python
flipped its quote state and the whole script failed to parse ("unexpected
EOF while looking for matching"), breaking just relay / just setup on a
default macOS toolchain.

Move host derivation to scripts/seed-hosts.py and the upsert to
scripts/seed-communities.sql; the shell now only wires them together and
never parses their source. Seeded loopback authorities are unchanged.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@cameronhotchkies cameronhotchkies marked this pull request as ready for review June 29, 2026 19:27

@wesbillman wesbillman left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Adversarial pass found no blockers.

What I checked:

  • The extracted scripts/seed-hosts.py preserves the old host derivation behavior for default loopback, 127.0.0.1, default ws/wss ports, non-loopback hosts, IPv6 loopback-shaped hosts, and invalid/empty RELAY_URL cases.
  • /bin/bash 3.2 parses the wrapper now (/bin/bash -n scripts/seed-local-community.sh).
  • scripts/seed-hosts.py compiles with py_compile.
  • scripts/seed-communities.sql correctly consumes the newline-separated :hosts psql variable via both direct psql -f and docker-stdin style, and remains idempotent.
  • Full isolated migration + seed against a temporary Postgres DB succeeded; second seed was INSERT 0 0 and the resulting rows were the expected four loopback authorities.

Validation:

  • /bin/bash -n scripts/seed-local-community.sh
  • python3 -m py_compile scripts/seed-hosts.py
  • git diff --check origin/main...HEAD
  • isolated buzz-admin migrate + scripts/seed-local-community.sh twice on a temp DB

No CHANGE comments from me.

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.

2 participants