Skip to content

Fly deploy: stop double-escaping secret values#40

Merged
dougdevitre merged 1 commit into
mainfrom
claude/fly-secrets-no-escape
May 16, 2026
Merged

Fly deploy: stop double-escaping secret values#40
dougdevitre merged 1 commit into
mainfrom
claude/fly-secrets-no-escape

Conversation

@dougdevitre
Copy link
Copy Markdown
Owner

Why

Boot logs from the last Fly machine showed:

{"err":"Invalid JSON: Unexpected token '\\', \"\\{\\\"+13143\"... is not valid JSON",
 "msg":"INBOUND_PHONE_VOICE_MAP — falling back to empty map"}

The workflow's "Pull runtime secrets" step wrote KEY=VALUE entries with printf '%q' (shell-quoted), then "Stage Fly secrets" read them back and passed them straight to fly secrets set without re-evaluating the quotes. The backslashes from %q survived all the way to Fly storage, then the app's JSON parser choked on them.

Fix

Switch to NUL-separated KEY=VALUE pairs:

  • Write: printf '%s=%s\0' "$name" "$value" >> $RUNNER_TEMP/secrets.bin
  • Read: while IFS= read -r -d '' pair; do args+=("$pair"); done
  • Pass: fly secrets set "${args[@]}" (quoted array, each pair = one argv entry)

Values arrive at Fly literally, no escaping. Removes the shellcheck SC2068 disable comment because the quoting is now correct.

Test plan


Generated by Claude Code

The previous "Pull runtime secrets" step wrote KEY=VALUE entries with
printf '%q' (shell-quoted), then the "Stage Fly secrets" step read
them back and passed them to fly secrets set without re-evaluating
the quotes. The escape characters survived all the way to Fly's
storage, so INBOUND_PHONE_VOICE_MAP ended up as the literal string
{"+13143..."} (with backslashes), which the JSON parser rejected at
boot with "Invalid JSON: Unexpected token '\\'".

Fix: switch to NUL-separated KEY=VALUE pairs in a temp file. The
write side uses printf '%s=%s\0' and the read side uses
read -d '' to consume the NUL delimiter. Quote the array expansion
to keep each pair as one argv entry to flyctl. Result: values
arrive at Fly literally, no escapes.

This also removes the shellcheck SC2068 disable comment because the
quoting is now correct.
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cotrackpro-talk Ready Ready Preview, Comment May 16, 2026 4:52pm

Request Review

@dougdevitre dougdevitre merged commit 8dcc42e into main May 16, 2026
3 checks passed
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