{"record":{"id":"fa974a0f8ee4f672","repo":"windmill-labs/windmill","slug":"failed-to-generate-lockfile-json-stringify-resu-fa974a","errorCode":null,"errorMessage":"Failed to generate lockfile: ${JSON.stringify(result, null, 2)}","messagePattern":"Failed to generate lockfile: (.+?)","errorType":"exception","errorClass":"LockfileGenerationError","httpStatus":null,"severity":"error","filePath":"cli/src/utils/metadata.ts","lineNumber":673,"sourceCode":"      { label: `deps ${remotePath}` },\n    );\n  } catch (e: any) {\n    throw new LockfileGenerationError(\n      `Failed to poll dependencies job ${jobId}: ${e?.message ?? e}`\n    );\n  }\n\n  const result = completion.result as any;\n  if (!completion.success) {\n    const message =\n      result?.error?.message ??\n      (typeof result === \"string\" ? result : JSON.stringify(result, null, 2));\n    throw new LockfileGenerationError(`Failed to generate lockfile: ${message}`);\n  }\n\n  const lock = result?.lock;\n  if (lock === undefined) {\n    throw new LockfileGenerationError(\n      `Failed to generate lockfile: ${JSON.stringify(result, null, 2)}`\n    );\n  }\n  if (cacheKey) {\n    lockCache.set(cacheKey, lock);\n  }\n  return lock;\n}\n\nasync function updateScriptLock(\n  workspace: Workspace,\n  scriptContent: string,\n  language: ScriptLanguage,\n  remotePath: string,\n  metadataContent: Record<string, any>,\n  rawWorkspaceDependencies: Record<string, string>,\n  tempScriptRefs?: Record<string, string>,\n  lockPathOverride?: string,","sourceCodeStart":655,"sourceCodeEnd":691,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/cli/src/utils/metadata.ts#L655-L691","documentation":"The dependencies job succeeded (completion.success === true) but its result did not contain a `lock` field, so there is no lockfile to return. The CLI throws this LockfileGenerationError with the full JSON-dumped result so you can inspect what the job actually produced. This indicates a contract mismatch between the job's output shape and what the CLI expects.","triggerScenarios":"The job result lacks result.lock — e.g. an older/newer Windmill server whose dependencies job returns a different result shape, a job that returned success with an empty/partial payload, or a proxy mocking the API returning {\"success\": true} without the lock payload.","commonSituations":"CLI and server version skew (CLI expecting a `lock` field the deployed server's dependency job doesn't emit); custom/self-hosted patches to the dependencies job; a stubbed API gateway used in tests returning a success result without a lock.","solutions":["Upgrade or align the wmill CLI version with your server version (`wmill version` vs instance version; `npm i -g windmill-cli@latest`)","Inspect the JSON in the message to see what the job returned and whether `lock` is nested under a different key","Check for self-hosted modifications to the dependencies_async job that change its result shape","If behind a mock/gateway, fix the stub to return { success: true, result: { lock: \"...\" } }","Work around locally by committing the lockfile directly and skipping remote generation, then report the version mismatch"],"exampleFix":"// before: server returns success without lock, CLI fails\n{\"success\": true, \"result\": {\"ok\": true}}\n// after: align server/CLI so result carries the lock\n{\"success\": true, \"result\": {\"lock\": \"numpy==1.26.4\\n...\"}}","handlingStrategy":"type-guard","validationCode":"// validate the expected job result shape before using it\nfunction looksLikeLockResult(result: any): boolean {\n  return result != null && typeof result === \"object\" && typeof result.lock === \"string\";\n}","typeGuard":"function hasLock(\n  result: any,\n): result is { lock: string } {\n  return (\n    result != null &&\n    typeof result === \"object\" &&\n    typeof result.lock === \"string\" &&\n    result.lock.length > 0\n  );\n}","tryCatchPattern":"try {\n  const lock = await fetchScriptLock(workspace, content, language, path, deps);\n} catch (e) {\n  if (e instanceof LockfileGenerationError && e.message.includes(\"{\\\"\")) {\n    log.error(\n      \"Dependencies job returned no lock payload — likely CLI/server version mismatch. \" +\n      \"Run `wmill version` and align the CLI with your instance, or inspect the returned JSON: \" + e.message\n    );\n  } else throw e;\n}","preventionTips":["Keep the wmill CLI version in sync with your Windmill server version","After upgrading either side, re-run a small push to verify the job result contract still holds","Watch for self-hosted modifications to the dependencies_async job that change its result shape","Commit lockfiles to the repo so a failed remote generation is non-blocking"],"tags":["lockfile","version-mismatch","cli","windmill"],"backgroundTag":"unexpected-response-shape","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"}