pulumi/pulumi · error

Unknown type:

Error message

Unknown type: 

What it means

This is thrown by the type-mapping function in the automation generator when it encounters a Pulumi schema type string it cannot translate into a TypeScript type. The switch statement handles a fixed set of known types (e.g. "string", "boolean", "int" → "number"); anything else — an unmapped schema primitive, an enum value name, or a differently-cased type — falls through to the default case and throws, with the offending type appended to the message.

Source

Thrown at sdk/nodejs/tools/automation/src/index.ts:358

 */
function convertType(type: string, repeatable: boolean): string {
    let base: string = "";

    switch (type) {
        case "string":
            base = "string";
            break;

        case "boolean":
            base = "boolean";
            break;

        case "int":
            base = "number";
            break;

        default:
            throw new Error("Unknown type: " + type);
    }

    return repeatable ? base + "[]" : base;
}

/** Convert a list of subcommand breadcrumbs into the unconfigured CLI command. */
function createCommandName(breadcrumbs: string[]): string {
    return "pulumi " + breadcrumbs.join(" ");
}

/** Convert a flag or argument name into a valid TypeScript property name. */
function sanitiseValueName(name: string): string {
    const suffix: string = reservedWords.includes(name) ? "_" : "";
    return camelCase(name) + suffix;
}

/** Convert a list of subcommand breadcrumbs into the options type name. */
function createOptionsTypeName(breadcrumbs: string[]): string {

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Read the type name in the error message and add a corresponding case to the switch in the type-mapping function in sdk/nodejs/tools/automation/src/index.ts
  2. Fix typos in the input schema/spec (e.g. change `integer` to `int` if that is the expected convention)
  3. Downgrade to a schema version whose types are all covered by the generator

Example fix

// before
case "int":
    base = "number";
    break;
default:
    throw new Error("Unknown type: " + type);

// after
case "int":
case "integer":
case "double":
    base = "number";
    break;
default:
    throw new Error("Unknown type: " + type);
Defensive patterns

Strategy: validation

Validate before calling

const KNOWN_TYPES = new Set(["string", "boolean", "int", "number", "any"]);
function assertAllTypesKnown(spec: { properties: { type: string }[] }) {
  for (const p of spec.properties) {
    if (!KNOWN_TYPES.has(p.type)) throw new Error(`spec uses unmapped type: ${p.type}`);
  }
}

Type guard

function isKnownType(type: string): type is "string" | "boolean" | "int" {
  return ["string", "boolean", "int"].includes(type);
}

Try / catch

try {
  generateOptionsTypes(spec, source);
} catch (e) {
  const m = /Unknown type: (.+)/.exec(String(e));
  if (m) console.error(`Add a mapping for '${m[1]}' to the type table`);
  throw e;
}

Prevention

When it happens

Trigger: Regenerating the automation CLI against a Pulumi schema/spec containing a property type not present in the switch's known cases, such as `integer` (instead of `int`), `float`, or a provider-specific type string.

Common situations: Upgrading a provider or Pulumi schema version that introduces new primitive type names, hand-editing the spec with a typo, or adding a new type to the spec without extending the generator's mapping table.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/ca3a520bc6a08218. Report an issue: GitHub.