Skip to content

fix(register.sh): handle space after colon in JSON response for builder_code#84

Open
erhnysr wants to merge 1 commit into
base:masterfrom
erhnysr:fix/register-sh-builder-code-json-parse
Open

fix(register.sh): handle space after colon in JSON response for builder_code#84
erhnysr wants to merge 1 commit into
base:masterfrom
erhnysr:fix/register-sh-builder-code-json-parse

Conversation

@erhnysr
Copy link
Copy Markdown

@erhnysr erhnysr commented Jun 6, 2026

Problem

Fixes #54.

The grep pattern on line 21 of register.sh requires no space between : and " in the JSON response:

# Old — fails on spaced JSON ("builder_code": "bc_...")
BUILDER_CODE=$(echo "$RESPONSE" | grep -o '"builder_code":"[^"]*"' | cut -d'"' -f4)

However, the reference doc (references/agents/register.md) shows the API response with a space after the colon. When the API returns spaced JSON, BUILDER_CODE is empty and the script exits 1 — registration silently fails.

Fix

Use a space-tolerant grep pattern (no new dependencies):

# New — handles both compact and spaced JSON
BUILDER_CODE=$(echo "$RESPONSE" | grep -o '"builder_code": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"')

Verification

# Spaced (as shown in reference doc) — now works
echo '{"builder_code": "bc_a1b2c3d4","wallet_address":"0x123"}' | grep -o '"builder_code": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"'
# → bc_a1b2c3d4

# Compact — still works
echo '{"builder_code":"bc_a1b2c3d4","wallet_address":"0x123"}' | grep -o '"builder_code": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"'
# → bc_a1b2c3d4

@cb-heimdall
Copy link
Copy Markdown
Collaborator

🟡 Heimdall Review Status

Requirement Status More Info
Reviews 🟡 0/1
Denominator calculation
Show calculation
1 if user is bot 0
1 if user is external 0
2 if repo is sensitive 0
From .codeflow.yml 1
Additional review requirements
Show calculation
Max 0
0
From CODEOWNERS 0
Global minimum 0
Max 1
1
1 if commit is unverified 0
Sum 1

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.

register.sh: grep pattern fails when API response has space after colon in JSON key ("builder_code": vs "builder_code":")

2 participants