Skip to content

Output is showing '[error] Command failed: SyntaxError: Unexpected token 'U',  #382

@Gromski

Description

@Gromski
Diagnostic Information
Property Value
CLI Version 0.5.1
Node.js Version v24.5.0
OS darwin
OS Version 25.1.0
Architecture x64
Capabilities none
Claude CLI Version 2.0.50 (Claude Code)

Output is showing '[error] Command failed: SyntaxError: Unexpected token 'U',


Enhancement Request Analysis

Questions for Reporter

Question Answer
What specific iloom command were you running when you encountered this syntax error? @Gromski, to reply, please edit this issue to answer these questions.
What was the full error output including any stack trace or line numbers?
Do you have any custom settings in .iloom/settings.json or .iloom/settings.local.json that might be relevant?
Were you inside an active loom workspace or in the main repository when the error occurred?

Problem Summary
The CLI is encountering a JavaScript syntax error when parsing JSON, likely indicating malformed JSON response from an external CLI tool (GitHub CLI, Claude CLI, or Neon CLI) or corrupted configuration/cache data.

User Impact
This prevents successful command execution, blocking users from creating new looms, finishing work, or running other iloom commands that depend on JSON parsing from external tools.

Enhancement Goal
Implement robust error handling and recovery for JSON parsing operations throughout the codebase, with clear error messages indicating which specific operation failed and how to resolve it.

Next Steps

  • Reporter to answer questions above for full context
  • Investigate JSON parsing points in GitHubService, ClaudeService, and SettingsManager
  • Add defensive parsing with detailed error context for debugging

📋 Complete Context & Details (click to expand)

Current Behavior
Based on the error message pattern "SyntaxError: Unexpected token 'U'", this typically occurs when:

  1. JSON.parse() receives undefined as input (starts parsing "undefined" and hits 'U')
  2. An external CLI tool returns non-JSON output when JSON is expected
  3. A configuration file contains invalid JSON syntax

Key areas in iloom that parse JSON:

  • GitHubService (src/lib/GitHubService.ts): Parses GitHub CLI output for issues/PRs
  • SettingsManager (src/lib/SettingsManager.ts): Loads .iloom/settings.json and .iloom/settings.local.json
  • AgentManager (src/lib/AgentManager.ts): Parses agent responses
  • Various utility functions that handle CLI command outputs

Proposed Solution

  1. Add try-catch blocks with context-aware error messages around all JSON.parse() calls
  2. Implement a centralized safeJsonParse utility that:
    • Validates input is not undefined/null before parsing
    • Provides detailed error context (what was being parsed, from which source)
    • Suggests remediation steps
  3. Add validation for external CLI tool outputs before parsing
  4. Implement fallback/recovery mechanisms where appropriate

Benefits

  • Users get clear, actionable error messages instead of cryptic syntax errors
  • Easier debugging with context about which specific operation failed
  • Improved reliability when dealing with external CLI tools
  • Better handling of edge cases and corrupted data scenarios

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions