Skip to content

Fix describe_outputs crash when tool_state is a dict not a JSON string#1654

Merged
mvdbeek merged 1 commit into
galaxyproject:masterfrom
jmchilton:fix-describe-outputs-dict-tool-state
Jul 1, 2026
Merged

Fix describe_outputs crash when tool_state is a dict not a JSON string#1654
mvdbeek merged 1 commit into
galaxyproject:masterfrom
jmchilton:fix-describe-outputs-dict-tool-state

Conversation

@jmchilton

Copy link
Copy Markdown
Member

Problem

describe_outputs (planemo/galaxy/workflows.py) read step tool_state with an unconditional json.loads:

tool_state = json.loads(step.get("tool_state", "{}"))

Some .ga workflows carry tool_state as an already-decoded dict rather than a JSON-encoded string. On those, json.loads raises:

TypeError: the JSON object must be str, bytes or bytearray, not dict

This fires on the planemo test / report path (via get_outputsdescribe_outputs) for a workflow that otherwise runs green.

Fix

Guard on type before decoding — the exact pattern already merged for the lint path in #1626, which missed this second call site. This keeps workflow_lint and planemo test consistent in how they tolerate dict tool_state:

raw_tool_state = step.get("tool_state", {})
if isinstance(raw_tool_state, str):
    tool_state = json.loads(raw_tool_state)
else:
    tool_state = raw_tool_state

Test

Adds test_describe_outputs_dict_tool_state, reusing the existing wf14-unlinted-best-practices-dict-tool-state.ga fixture (its step 0 has tool_id: null + dict tool_state — exactly this path). Verified red→green: without the fix the test reproduces the TypeError; with it, the file's tests pass.

🤖 Generated with Claude Code

After a green run .ga files can carry tool_state as a dict rather than a
JSON-encoded string; json.loads then raised TypeError. Mirror the guard
already used in the lint path (PR galaxyproject#1626).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mvdbeek mvdbeek merged commit ae45395 into galaxyproject:master Jul 1, 2026
15 checks passed
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.

2 participants