- _extract_token.py: narrow `except Exception` to `except (json.JSONDecodeError, ValueError)`. Prevents swallowing KeyboardInterrupt in edge cases and documents intent clearly. - ci.yml shellcheck job: switch to ludeeus/action-shellcheck@master (caches shellcheck binary across runs; saves the apt-get install). Both changes verified locally: YAML parses, extract script still extracts valid tokens and prints the stderr warning on malformed JSON. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
25 lines
830 B
Python
Executable File
25 lines
830 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""Stdin: JSON response from POST /registry/register.
|
|
Stdout: the auth_token value, or empty string.
|
|
Stderr: diagnostic when the response is unparseable or missing a token.
|
|
|
|
Exit code is always 0 — the empty string on stdout is how callers
|
|
distinguish "no token issued" (legitimate on re-registration) from
|
|
success. The warning on stderr surfaces the no-token case so it
|
|
stops masking downstream "missing workspace auth token" 401s.
|
|
"""
|
|
import json
|
|
import sys
|
|
|
|
try:
|
|
data = json.load(sys.stdin)
|
|
except (json.JSONDecodeError, ValueError) as e:
|
|
sys.stderr.write(f"e2e_extract_token: invalid JSON response ({e})\n")
|
|
print("")
|
|
raise SystemExit(0)
|
|
|
|
token = data.get("auth_token", "")
|
|
if not token:
|
|
sys.stderr.write("e2e_extract_token: response contained no auth_token field\n")
|
|
print(token)
|