windmill-labs/windmill · warning

Could not pull resource types and generate TypeScript namesp

Error message

Could not pull resource types and generate TypeScript namespace: ${error instanceof Error ? error.message : error}

What it means

When `wmill init` binds a new workspace (didBindWorkspace is true), it immediately pulls the resource types from the backend and generates the TypeScript resource-type namespace via generateRTNamespace. A failure there — network, auth, or codegen — is caught and logged as this warning; init completes without the generated namespace.

Source

Thrown at cli/src/commands/init/init.ts:262

  try {
    await refreshTsconfig({ yes: opts.useDefault === true });
  } catch (error) {
    log.warn(
      `Could not generate tsconfig: ${
        error instanceof Error ? error.message : error
      }`
    );
  }

  // Generate resource type namespace (needs a bound workspace)
  if (didBindWorkspace && boundProfile) {
    try {
      // Cache the bound profile so resolveWorkspace doesn't re-resolve and prompt again
      const rtOpts = { ...opts } as GlobalOptions;
      (rtOpts as any).__secret_workspace = boundProfile;
      await generateRTNamespace(rtOpts);
    } catch (error) {
      log.warn(
        `Could not pull resource types and generate TypeScript namespace: ${
          error instanceof Error ? error.message : error
        }`
      );
    }
  } else {
    // generateRTNamespace resolves a workspace; its non-interactive
    // multiple-workspaces path process.exit(-1)s (uncatchable), aborting init.
    // So generate only for a single resolvable workspace (baseUrl + matching
    // profile), passed via __secret_workspace to skip resolution; else skip.
    const { readConfigFile, getWorkspaceNames, getEffectiveWorkspaceId } =
      await import("../../core/conf.ts");
    const config = await readConfigFile({ warnIfMissing: false });
    const resolvable = getWorkspaceNames(config.workspaces).filter(
      (n) => !!(config.workspaces as any)?.[n]?.baseUrl
    );
    let boundProfileForGen: Workspace | undefined;
    if (resolvable.length === 1) {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Confirm the workspace is reachable and authenticated: `wmill workspace list` then a cheap authenticated call like `wmill user whoami`.
  2. Re-run namespace generation later with the dedicated command (e.g. `wmill resource-type generate-namespace` / re-run `wmill init`) once connectivity is restored.
  3. Verify the token's permissions include reading resource types on that workspace.
  4. If generation keeps failing on write, ensure the target directory is writable and re-run.
  5. Read the warning body for the exact underlying cause (401/403 vs network vs fs error).

Example fix

// before
wmill init   # fails to generate namespace; continue manually later
// after
wmill init && wmill resource-type generate-namespace   # retry codegen explicitly
Defensive patterns

Strategy: try-catch

Validate before calling

// verify the bound workspace works before generating the namespace
const who = await fetch(`${boundProfile.remote}/api/w/${boundProfile.workspaceId}/workers/queues`, {
  headers: { Authorization: `Bearer ${boundProfile.token}` },
});
if (!who.ok) console.warn(`resource type fetch will fail: HTTP ${who.status}`);

Type guard

function hasErrorMessage(error: unknown): error is Error {
  return error instanceof Error && typeof error.message === "string";
}

Try / catch

try {
  await generateRTNamespace(rtOpts);
} catch (error) {
  log.warn(`Could not pull resource types and generate TypeScript namespace: ${hasErrorMessage(error) ? error.message : error}`);
}

Prevention

When it happens

Trigger: `wmill init` with a freshly bound workspace when generateRTNamespace fails: backend unreachable, invalid token, the workspace has no permission to list resource types, or writing the generated namespace file (e.g. backend/windmill-resource-types or similar) fails on disk.

Common situations: Token lacks access to resource types on a self-hosted instance; offline environment; workspace bound to a remote whose API version predates the resource-type endpoints; read-only checkout preventing the generated file from being written.

Related errors


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