Repository navigation
fix(plugins): keep the standup sweep output when a CLI call prints nothing - #9386
aaronrosenthal wants to merge 1 commit into
Conversation
…thing run_json passed an empty stdout through as valid, because jq accepts empty input. The empty value then failed --argjson in the terminal loop, which emptied TERMINALS and made the final jq print nothing at all. run_json now returns null for empty output, and the loop skips a terminal with no entry. The bash 3.2 unbound HOST_ARGS error in ParadevAI#9196 is already gone on main: ParadevAI#9257 made HOST_ARGS default to (--local), so it is never empty. superset plugin 0.3.5. Closes ParadevAI#9196 Co-Authored-By: Claude <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
There was a problem hiding this comment.
1 issue found across 3 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="plugins/superset/skills/standup/scripts/sweep.sh">
<violation number="1" location="plugins/superset/skills/standup/scripts/sweep.sh:34">
P2: This check misses whitespace-only CLI output: `jq` succeeds but emits no value, so `run_json` returns an empty string and a later `--argjson` fails. Also require the parsed input to contain a value, such as by adding `jq -e -s 'length == 0'` to this condition.</violation>
</file>
Architecture diagram
sequenceDiagram
participant SHELL as sweep.sh
participant CLI as superset CLI
participant JQ as jq processor
participant JSON as JSON Accumulator
Note over SHELL,JSON: Standup Sweep Data Flow (Preserving JSON output on empty CLI results)
SHELL->>SHELL: Initialize WORKSPACES via run_json
loop For each workspace
SHELL->>CLI: run_json workspaces list --json
CLI-->>SHELL: Workspace JSON stdout
SHELL->>JQ: Parse workspace JSON (jq -r '.[]?.id // empty')
JQ-->>SHELL: Workspace IDs
end
loop For each workspace, for each terminal
SHELL->>CLI: run_json terminals list --workspace WS --json
CLI-->>SHELL: Terminal list JSON stdout
SHELL->>JQ: Extract terminal IDs
JQ-->>SHELL: Terminal IDs
SHELL->>CLI: run_json terminals read --workspace WS --terminal ID --json
CLI-->>SHELL: Terminal output (may be empty)
alt Empty stdout from CLI
SHELL->>SHELL: Check if output file is empty (test -s)
SHELL->>SHELL: Log "no output from: superset ..." to stderr
SHELL->>SHELL: Return null
else Non-empty stdout
SHELL->>JQ: Validate and parse JSON (jq -c .)
alt Invalid JSON
SHELL->>SHELL: Log "invalid JSON from: superset ..." to stderr
SHELL->>SHELL: Return null
else Valid JSON
JQ-->>SHELL: Parsed JSON value
end
end
SHELL->>JQ: Build terminal entry with --argjson read (null fallback)
JQ-->>SHELL: Terminal entry JSON
alt Entry is not empty
SHELL->>JQ: Append entry to TERMINALS array (--argjson e)
else Entry is empty or null
SHELL->>SHELL: Skip terminal (continue)
end
end
Note over SHELL,JSON: Final JSON output preserves workspaces, tasks, and terminals even when CLI calls return empty output
Reply to a comment to ask cubic a question or push back. It learns from your replies.
View guided diff | Re-trigger cubic
| err=$(mktemp) || { rm -f "$out"; echo null; return; } | ||
| if superset "$@" --json >"$out" 2>"$err"; then | ||
| if ! jq -c '.' "$out" 2>/dev/null; then | ||
| if [ ! -s "$out" ]; then |
There was a problem hiding this comment.
P2: This check misses whitespace-only CLI output: jq succeeds but emits no value, so run_json returns an empty string and a later --argjson fails. Also require the parsed input to contain a value, such as by adding jq -e -s 'length == 0' to this condition.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At plugins/superset/skills/standup/scripts/sweep.sh, line 34:
<comment>This check misses whitespace-only CLI output: `jq` succeeds but emits no value, so `run_json` returns an empty string and a later `--argjson` fails. Also require the parsed input to contain a value, such as by adding `jq -e -s 'length == 0'` to this condition.</comment>
<file context>
@@ -31,7 +31,10 @@ run_json() {
err=$(mktemp) || { rm -f "$out"; echo null; return; }
if superset "$@" --json >"$out" 2>"$err"; then
- if ! jq -c '.' "$out" 2>/dev/null; then
+ if [ ! -s "$out" ]; then
+ echo "no output from: superset $*" >&2
+ echo null
</file context>
| if [ ! -s "$out" ]; then | |
| if [ ! -s "$out" ] || jq -e -s 'length == 0' "$out" >/dev/null 2>&1; then |
What & why
Fixes #9196.
The headline bug in #9196 (
HOST_ARGS[@]: unbound variableon macOS bash 3.2) is already fixed onmain. #9257 setHOST_ARGS=(--local)as the default, so the array is never empty. I ran the current script under/bin/bash3.2.57 and terminals come back correctly.This PR fixes the related problem the triage found in the same loop:
run_jsontreated empty stdout as valid, becausejq -c . <empty>exits 0 and prints nothing. The emptyREADthen failed--argjson read "". That emptiedTERMINALS, and the finaljqfailed, so the sweep printed no JSON at all.run_jsonnow returnsnull(and logsno output from: …) when stdout is empty.ENTRYis empty instead of passing""to--argjson.supersetplugin goes to 0.3.5 in bothplugin.jsonfiles, the same way feat(cli): cloud workspace commands that work while the sandbox sleeps #9257 bumped it to 0.3.4.How I tested it
I put a stub
supersetonPATHand ransweep.shwith macOS/bin/bash3.2.57:--host, normal output: workspaces, tasks, and terminals (withtext) are all present, before and after this change.terminals readprints nothing: before,jq: invalid JSON text passed to --argjsonand no JSON on stdout. After, full JSON with"text": nullfor that terminal.bun run check:pluginspasses.biome check plugins/supersetis clean.There are no TS changes, so I didn't run
typecheck/test.Checklist
type(scope): subject)bun run lintandbun run typecheckpass (only shell/JSON changed; biome clean on the touched files)Summary by cubic
Fixes the standup sweep so it still outputs JSON when a CLI call prints nothing.
When
superset terminals readproduced empty stdout,run_jsontreated it as valid output, the empty value failed--argjson, and the sweep ended up printing no JSON at all.run_jsonnow returnsnulland logsno output from: ...when stdout is empty, and the loop skips a terminal with no entry instead of passing""to--argjson.Also bumps the
supersetplugin to 0.3.5 in bothplugin.jsonfiles.Written for commit 6037a56. Summary will update on new commits.
Summary by CodeRabbit