windmill-labs/windmill · warning

{"error": "<parse error string>"}

Error message

{"error": "<parse error string>"}

What it means

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.

Source

Thrown at backend/parsers/windmill-parser-wasm/src/lib.rs:36

#[cfg(feature = "ts-parser")]
#[wasm_bindgen]
pub fn parse_deno(code: &str, main_override: Option<String>) -> String {
    wrap_sig(windmill_parser_ts::parse_deno_signature(
        code,
        false,
        false,
        main_override,
    ))
}

#[cfg(feature = "ts-parser")]
#[wasm_bindgen]
pub fn parse_outputs(code: &str) -> String {
    let parsed = parse_expr_for_ids(code);
    let r = if let Ok(parsed) = parsed {
        json!({ "outputs": parsed })
    } else {
        json!({"error": parsed.err().unwrap().to_string()})
    };
    return serde_json::to_string(&r).unwrap();
}

/// Parse TypeScript imports and return raw import strings.
/// See [`parse_ts_relative_imports`] for resolved absolute paths.
#[cfg(feature = "ts-parser")]
#[wasm_bindgen]
pub fn parse_ts_imports(code: &str) -> String {
    let parsed = parse_expr_for_imports(code, false);
    let r = if let Ok(parsed) = parsed {
        json!({ "imports": parsed })
    } else {
        json!({"error": parsed.err().unwrap().to_string()})
    };
    return serde_json::to_string(&r).unwrap();
}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Read the 'error' field of the returned JSON and fix the syntax error in the code
  2. Validate the script compiles in the Windmill editor before parsing
  3. Update the parser/wasm crate if the code uses recently added TS/JS syntax

Example fix

// before
const r = JSON.parse(parse_outputs(code));
console.log(r.outputs);
// after
const r = JSON.parse(parse_outputs(code));
if (r.error) { console.error('Parse failed:', r.error); } else { console.log(r.outputs); }
Defensive patterns

Strategy: type-guard

Validate before calling

const result = JSON.parse(parse_outputs(code));
if (typeof result.error === 'string') throw new Error(result.error);

Type guard

function hasOutputs(r: unknown): r is { outputs: string[] } {
  return typeof r === 'object' && r !== null && 'outputs' in r;
}

Try / catch

const parsed = JSON.parse(parse_outputs(code));
if (parsed.error) {
  console.error('parse_outputs failed:', parsed.error);
} else {
  useOutputs(parsed.outputs);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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).

Understand the failure class

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/d30b0868ab09dd15. Report an issue: GitHub.