{"record":{"id":"d30b0868ab09dd15","repo":"windmill-labs/windmill","slug":"error-parse-error-string","errorCode":null,"errorMessage":"{\"error\": \"<parse error string>\"}","messagePattern":"\\{\"error\": \"<parse error string>\"\\}","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"backend/parsers/windmill-parser-wasm/src/lib.rs","lineNumber":36,"sourceCode":"#[cfg(feature = \"ts-parser\")]\n#[wasm_bindgen]\npub fn parse_deno(code: &str, main_override: Option<String>) -> String {\n    wrap_sig(windmill_parser_ts::parse_deno_signature(\n        code,\n        false,\n        false,\n        main_override,\n    ))\n}\n\n#[cfg(feature = \"ts-parser\")]\n#[wasm_bindgen]\npub fn parse_outputs(code: &str) -> String {\n    let parsed = parse_expr_for_ids(code);\n    let r = if let Ok(parsed) = parsed {\n        json!({ \"outputs\": parsed })\n    } else {\n        json!({\"error\": parsed.err().unwrap().to_string()})\n    };\n    return serde_json::to_string(&r).unwrap();\n}\n\n/// Parse TypeScript imports and return raw import strings.\n/// See [`parse_ts_relative_imports`] for resolved absolute paths.\n#[cfg(feature = \"ts-parser\")]\n#[wasm_bindgen]\npub fn parse_ts_imports(code: &str) -> String {\n    let parsed = parse_expr_for_imports(code, false);\n    let r = if let Ok(parsed) = parsed {\n        json!({ \"imports\": parsed })\n    } else {\n        json!({\"error\": parsed.err().unwrap().to_string()})\n    };\n    return serde_json::to_string(&r).unwrap();\n}\n","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/backend/parsers/windmill-parser-wasm/src/lib.rs#L18-L54","documentation":"parse_outputs is a WASM-exported parser used by the frontend/CLI to extract output IDs from TypeScript code. On parse failure it does not throw; it returns a JSON envelope {\"error\": \"<message>\"} so callers can detect and display the parse error.","triggerScenarios":"Calling parse_outputs(code) with TypeScript that the underlying expression parser cannot parse (syntax errors, unsupported syntax), causing parse_expr_for_ids to return Err.","commonSituations":"Analyzing a script with a genuine syntax error; pasting non-TS code; a parser/wasm toolchain that lacks support for newer TS syntax (e.g. very new stage proposals).","solutions":["Read the 'error' field of the returned JSON and fix the syntax error in the code","Validate the script compiles in the Windmill editor before parsing","Update the parser/wasm crate if the code uses recently added TS/JS syntax"],"exampleFix":"// before\nconst r = JSON.parse(parse_outputs(code));\nconsole.log(r.outputs);\n// after\nconst r = JSON.parse(parse_outputs(code));\nif (r.error) { console.error('Parse failed:', r.error); } else { console.log(r.outputs); }","handlingStrategy":"type-guard","validationCode":"const result = JSON.parse(parse_outputs(code));\nif (typeof result.error === 'string') throw new Error(result.error);","typeGuard":"function hasOutputs(r: unknown): r is { outputs: string[] } {\n  return typeof r === 'object' && r !== null && 'outputs' in r;\n}","tryCatchPattern":"const parsed = JSON.parse(parse_outputs(code));\nif (parsed.error) {\n  console.error('parse_outputs failed:', parsed.error);\n} else {\n  useOutputs(parsed.outputs);\n}","preventionTips":["Precompile/lint the TypeScript before parsing","Remember parse_outputs returns an error envelope, not a thrown exception — always check the 'error' key","Keep the parser/wasm toolchain updated for newer TS syntax"],"tags":["parser","typescript","wasm"],"backgroundTag":"typescript-parse-error","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"}