eas-cli icon indicating copy to clipboard operation
eas-cli copied to clipboard

fingerprint:generate --environment --json prints the env-variables notice to stdout, so the JSON can't be parsed

Open jnvai opened this issue 1 month ago • 0 comments

Build/Submit details page URL

N/A (local command; also reproduced on GitHub Actions)

Summary

eas fingerprint:generate --environment <env> --json prints the "Environment variables with visibility … loaded from the "" environment on EAS: …" notice to stdout, before the JSON, so the output isn't valid JSON and jq (or JSON.parse) fails. The other progress lines ("🔧 Using environment", "Computing project fingerprint") correctly go to stderr.

Managed or bare?

Managed (CNG, no native directories in the repo)

Environment

  • eas-cli 24.11.0 on GitHub Actions (ubuntu-latest, Node 24), and eas-cli 20.1.0 on macOS (Node 24.14.0).
  • The relevant code is unchanged on main (eas-cli 25.3.0), so I expect it still reproduces there.

Error output

stdout of eas fingerprint:generate --environment preview --platform ios --json --non-interactive 2>/dev/null (variable names elided):

Environment variables with visibility "Plain text" and "Sensitive" loaded from the "preview" environment on EAS: …

{
  "sources": [
  …
  "hash": "…"
}

jq .hash on it:

jq: parse error: Invalid numeric literal at line 1, column 12

Reproducible demo or steps to reproduce from a blank project

  1. npx create-expo-app repro && cd repro && eas init
  2. Create any plain-text variable in the preview environment: eas env:create --environment preview --name FOO --value bar --visibility plaintext
  3. eas fingerprint:generate --environment preview --platform ios --json --non-interactive 2>/dev/null | jq .hash

Expected: the hash. Actual: the notice is on stdout and jq fails to parse it.

Cause, as far as I can tell: fingerprint/generate.ts passes withServerSideEnvironment: environment to getContextAsync(), and PrivateProjectConfigContextField then calls loadServerSideEnvironmentVariablesAsync(), which Log.logs the notice. That runs inside getContextAsync(), before enableJsonOutput() redirects stdout to stderr (generate.ts, the if (json) { enableJsonOutput(); } right after getContextAsync). Calling enableJsonOutput() before getContextAsync() when --json is set would fix it. Other commands that pass withServerSideEnvironment and support --json may have the same ordering.

Workaround: keep only the JSON from stdout, e.g. sed -n '/^{/,/^}/p' | jq .hash.

jnvai avatar Oct 24 '26 13:10 jnvai