{"record":{"id":"2d020a655cf41bbc","repo":"nexu-io/open-design","slug":"vela-command-returned-no-json-output","errorCode":null,"errorMessage":"Vela ${command} returned no JSON output","messagePattern":"Vela (.+?) returned no JSON output","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/daemon/src/media/vela.ts","lineNumber":78,"sourceCode":"const VELA_IMAGE_TIMEOUT_MS = 330_000;\nconst VELA_MODELS_TIMEOUT_MS = 30_000;\nconst VELA_VIDEO_SUBMIT_TIMEOUT_MS = 330_000;\nconst DEFAULT_VELA_VIDEO_POLL_COMMAND_TIMEOUT_MS = 90_000;\nconst DEFAULT_VELA_VIDEO_POLL_INTERVAL_MS = 5_000;\nconst DEFAULT_VELA_VIDEO_TOTAL_TIMEOUT_MS = 15 * 60_000;\nconst DEFAULT_VELA_VIDEO_RESOLUTION = '720p';\nconst VELA_MAX_INPUT_IMAGES = 5;\nconst VELA_VIDEO_RATIOS = new Set(['16:9', '9:16', '1:1']);\nconst VELA_VIDEO_DURATIONS = new Set([5, 10]);\n\nfunction isRecord(value: unknown): value is JsonRecord {\n  return value !== null && typeof value === 'object' && !Array.isArray(value);\n}\n\nfunction parseJsonObject(stdout: string, command: string): JsonRecord {\n  const trimmed = stdout.trim();\n  if (!trimmed) {\n    throw new Error(`Vela ${command} returned no JSON output`);\n  }\n  try {\n    const value: unknown = JSON.parse(trimmed);\n    if (!isRecord(value)) {\n      throw new Error('expected a JSON object');\n    }\n    return value;\n  } catch (error) {\n    const detail = error instanceof Error ? error.message : String(error);\n    throw new Error(`Vela ${command} returned invalid JSON: ${detail}`);\n  }\n}\n\nfunction nonEmptyString(value: unknown): string | null {\n  return typeof value === 'string' && value.trim() ? value.trim() : null;\n}\n\nfunction positiveIntegerFromEnv(name: string, fallback: number): number {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/nexu-io/open-design/blob/5be4028344c2eb4c667c5a97bda8f750c5597ef7/apps/daemon/src/media/vela.ts#L60-L96","documentation":"Thrown by parseJsonObject() in vela.ts when the Vela CLI's stdout is empty after trimming. The daemon expects every Vela command run with --json to emit a JSON object on stdout; an empty stdout means the CLI exited without producing the structured payload. The command name is interpolated so the caller knows which Vela subcommand failed.","triggerScenarios":"runCommand (a Vela CLI invocation) returns an empty string for commands like 'image gen', 'image edit', 'media models', or 'video gen'. Happens when the Vela binary writes errors to stderr only, when --json is not honored, or when a CLI crash produces no stdout.","commonSituations":"Vela CLI version that does not support --json for that subcommand; CLI crashed before emitting output; stderr-only error logging; the binary was killed (OOM / signal) before flushing stdout; misconfigured Vela workspace.","solutions":["Run the same Vela CLI command directly and inspect stderr for the real error","Confirm the installed Vela CLI version supports --json for the failing subcommand","Check Vela login state (vela login / the agent binary resolver) since auth failures can suppress JSON output","Ensure the workspace id (if passed) is valid and accessible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"function isNonEmptyStdout(stdout: string): boolean {\n  return stdout.trim().length > 0;\n}\n\nconst stdout = await runCommand(args, opts);\nif (!isNonEmptyStdout(stdout)) {\n  throw new Error(`Vela ${label} produced no stdout — check the CLI and stderr`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const stdout = await runCommand(args, opts);\n  const asset = parseJsonObject(stdout, label);\n} catch (err) {\n  if (err instanceof Error && /returned no JSON output/.test(err.message)) {\n    // capture vela stderr / version and surface a richer error\n  } else throw err;\n}","preventionTips":["Capture Vela CLI stderr alongside stdout so empty-stdout failures have a diagnostic","Pin the Vela CLI version and run a smoke test that the --json flag works after every upgrade","Verify Vela login state before the first media call in a session"],"tags":["vela","cli","json","parsing","upstream"],"backgroundTag":null,"analyzedSha":"5be4028344c2eb4c667c5a97bda8f750c5597ef7","analyzedAt":"2026-08-12T12:03:58.812Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}