Skip to content

enso bridge: parse pretty-printed --json output - #28

Open
nerdburn wants to merge 1 commit into
mainfrom
fix/bridge-pretty-json
Open

nerdburn wants to merge 1 commit into
mainfrom
fix/bridge-pretty-json

Conversation

@nerdburn

Copy link
Copy Markdown
Owner

Problem

lore_bridge.py dispatch crashes on its first real run:

File ".../lore_bridge.py", line 163, in dispatch
    if (t.get("claim") or {}).get("holder") == holder:
AttributeError: 'str' object has no attribute 'get'

lore work list --json (and enso's --json) print indented, multi-line JSON. last_json tried each line from the bottom first, and a line holding a bare string inside an array (a ticket's source URL, a task ref) is itself valid JSON, so the bridge got a string instead of the ticket list. Nothing was claimed before the crash. Found while enabling the bridge on athena for Marble (MC-444).

Fix

Parse the whole output first; failing that, parse the tail starting at the last line that opens an object or array, so output with log lines before the JSON still works.

Testing

Checked last_json against a pretty-printed list, log lines then a pretty list, compact JSON, an enso refusal ({"ok": false, "existing": {...}}) after a warning, and non-JSON. With this version on athena, dispatch claimed MC-444 and created enso task MARBLE-001.

🤖 Generated with Claude Code

lore and enso print --json results indented over many lines. last_json tried
each line from the bottom first, and a line that is a bare string inside an
array (a ticket's source URL, a task ref) is itself valid JSON, so dispatch got
a string back instead of the ticket list and crashed:

  AttributeError: 'str' object has no attribute 'get'   (dispatch, line 163)

Parse the whole output first, then the tail from the last line that opens an
object or array, so log lines before the JSON still work.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant