windmill-labs/windmill · error

Error parsing mocked API file at path

Error message

Error parsing mocked API file at path

What it means

Degrading warning while loading the mocked API in the TS client: the file at WM_MOCKED_API_FILE was read successfully but JSON.parse failed (malformed JSON). The parsed mock is discarded and the client falls through to the no-mock/empty path.

Source

Thrown at typescript-client/client.ts:1528

    console.info("Using mocked API from", mockedPath);
  } else {
    return undefined;
  }

  try {
    const fs = await import("node:fs/promises");
    const file = await fs.readFile(mockedPath, "utf-8");
    try {
      mockedApi = JSON.parse(file) as MockedApi;
      if (!mockedApi.variables) {
        mockedApi.variables = {};
      }
      if (!mockedApi.resources) {
        mockedApi.resources = {};
      }
      return mockedApi;
    } catch {
      console.warn("Error parsing mocked API file at path", mockedPath);
    }
  } catch {
    console.warn("Error reading mocked API file at path", mockedPath);
  }
  if (!mockedApi) {
    console.warn(
      "No mocked API file path provided at env variable WM_MOCKED_API_FILE. Using empty mocked API."
    );
    mockedApi = {
      variables: {},
      resources: {},
    };
    return mockedApi;
  }
}

interface MockedApi {
  variables: Record<string, string>;

View on GitHub (pinned to e474e8803c)

Solutions

  1. Validate the mocked API file's JSON (jsonschema/jq or a JSON linter) and fix the syntax error
  2. Confirm the file was written fully — partial writes produce invalid JSON
  3. Regenerate the mock file if produced by another tool
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at typescript-client/client.ts:1528 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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