{"record":{"id":"c4fb4bac1c2aa9ea","repo":"windmill-labs/windmill","slug":"outputs-error","errorCode":null,"errorMessage":"${outputs.error}","messagePattern":"\\$\\{outputs\\.error\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"frontend/src/lib/infer.ts","lineNumber":699,"sourceCode":"\t\t}\n\n\t\tawait inferArgs(script.language as SupportedLanguage, script.content, script.schema as any)\n\t\treturn { schema: script.schema as any, summary: script.summary }\n\t}\n}\n\nexport async function parseOutputs(\n\tcode: string,\n\tignoreError\n): Promise<[string, string][] | undefined> {\n\tawait initWasmTs()\n\tconst getOutputs = await parse_outputs(code)\n\tconst outputs = JSON.parse(getOutputs)\n\tif (outputs.error) {\n\t\tif (ignoreError) {\n\t\t\treturn undefined\n\t\t}\n\t\tthrow new Error(outputs.error)\n\t}\n\treturn outputs.error ? [] : outputs.outputs\n}\n\n/** JS fallback parser for R main() signatures when WASM parser is unavailable. */\nfunction parseRSignatureFallback(code: string): MainArgSignature {\n\tconst result: MainArgSignature = {\n\t\ttype: 'Valid',\n\t\terror: '',\n\t\tstar_args: false,\n\t\tstar_kwargs: false,\n\t\targs: [],\n\t\thas_preprocessor: null,\n\t\tauto_kind: null\n\t}\n\n\tconst mainMatch = code.match(/\\bmain\\s*(?:<-|=)\\s*function\\s*\\(([^)]*)\\)/)\n\tif (!mainMatch) {","sourceCodeStart":681,"sourceCodeEnd":717,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/infer.ts#L681-L717","documentation":"parseOutputs runs the `parse_outputs` analyzer on script code and parses its JSON result. If the result carries an `error` field, that error is thrown verbatim (unless ignoreError is set, in which case undefined is returned). It means the outputs analyzer failed to determine what the script returns — typically because the code is unparseable or uses return constructs the analyzer doesn't support.","triggerScenarios":"The `outputs()` accessor calls parseOutputs with ignoreError falsy and the analyzer returns { error } — e.g. code with syntax errors, dynamic/complex return statements the static analyzer can't resolve, or a parser/WASM failure.","commonSituations":"Scripts whose return values are computed dynamically (spread/conditional returns) confusing the analyzer; syntax-broken code saved anyway; unsupported language constructs in newer Python/TS versions; the analyzer WASM failing to load.","solutions":["Read the embedded error message — it states what the analyzer could not handle.","Make the return statement(s) statically analyzable (explicit, simple returns).","Fix any syntax errors in the script first.","Declare the outputs schema manually instead of relying on inference.","Pass ignoreError where outputs are optional, if you control the call, to degrade gracefully."],"exampleFix":"// before\nreturn { ...(cond ? {a: 1} : {b: 2}), [k]: v } // analyzer error\n// after\nconst out: { a?: number; b?: number } = {}\nif (cond) out.a = 1\nelse out.b = 2\nreturn out","handlingStrategy":"try-catch","validationCode":"// quick syntax gate before outputs inference\ntry { new Function(code) /* js/ts-ish smoke parse */ } catch (e) { throw new Error('fix syntax before outputs inference') }","typeGuard":"function hasAnalyzerError(o: { error?: string }): o is { error: string } {\n  return typeof o.error === 'string' && o.error.length > 0\n}","tryCatchPattern":"try {\n  const outs = await outputs(code)\n} catch (e) {\n  console.warn('outputs inference failed:', e.message)\n  return [] // or open manual outputs editor\n}","preventionTips":["Use explicit, statically analyzable return statements.","Fix syntax errors before triggering inference.","Declare outputs manually when returns are dynamic.","Use the ignoreError path when outputs are optional for the UI."],"tags":["outputs-inference","parser","static-analysis"],"backgroundTag":"schema-inference-failed","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}