Skip to content

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

@Nexory

Description

@Nexory

register.sh silently fails when the API returns JSON with a space after the colon

File: skills/build-on-base/scripts/register.sh, line 21

BUILDER_CODE=$(echo "$RESPONSE" | grep -o '"builder_code":"[^"]*"' | cut -d'"' -f4)

The pattern "builder_code":"[^"]*" requires no space between : and ". However, the repo's own reference doc (references/agents/register.md) shows the API response as:

{
  "builder_code": "bc_a1b2c3d4",
  "wallet_address": "0x...",
  "usage_instructions": "..."
}

That is "builder_code": "bc_..." — space after the colon. The grep pattern produces empty output on this format. When BUILDER_CODE is empty the script falls into the guard block, prints an error to stderr, and exits 1 — registration fails.

Reproduction (no API call needed):

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

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

Fix — two options:

# Option A: jq (robust, handles all valid JSON including pretty-printed)
BUILDER_CODE=$(echo "$RESPONSE" | jq -r '.builder_code // empty')

# Option B: space-tolerant grep, no jq dependency
BUILDER_CODE=$(echo "$RESPONSE" | grep -o '"builder_code": *"[^"]*"' | grep -o '"[^"]*"$' | tr -d '"')

Option A is preferred. Option B is a minimal diff that stays dependency-free.

The script's set -euo pipefail and existing empty-check guard prevent data corruption, but the registration command fails instead of succeeding, which blocks the workflow described in references/agents/register.md.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions