{"record":{"id":"ca3a520bc6a08218","repo":"pulumi/pulumi","slug":"unknown-type","errorCode":null,"errorMessage":"Unknown type: ","messagePattern":"Unknown type: ","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/nodejs/tools/automation/src/index.ts","lineNumber":358,"sourceCode":" */\nfunction convertType(type: string, repeatable: boolean): string {\n    let base: string = \"\";\n\n    switch (type) {\n        case \"string\":\n            base = \"string\";\n            break;\n\n        case \"boolean\":\n            base = \"boolean\";\n            break;\n\n        case \"int\":\n            base = \"number\";\n            break;\n\n        default:\n            throw new Error(\"Unknown type: \" + type);\n    }\n\n    return repeatable ? base + \"[]\" : base;\n}\n\n/** Convert a list of subcommand breadcrumbs into the unconfigured CLI command. */\nfunction createCommandName(breadcrumbs: string[]): string {\n    return \"pulumi \" + breadcrumbs.join(\" \");\n}\n\n/** Convert a flag or argument name into a valid TypeScript property name. */\nfunction sanitiseValueName(name: string): string {\n    const suffix: string = reservedWords.includes(name) ? \"_\" : \"\";\n    return camelCase(name) + suffix;\n}\n\n/** Convert a list of subcommand breadcrumbs into the options type name. */\nfunction createOptionsTypeName(breadcrumbs: string[]): string {","sourceCodeStart":340,"sourceCodeEnd":376,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/nodejs/tools/automation/src/index.ts#L340-L376","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["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","Fix typos in the input schema/spec (e.g. change `integer` to `int` if that is the expected convention)","Downgrade to a schema version whose types are all covered by the generator"],"exampleFix":"// before\ncase \"int\":\n    base = \"number\";\n    break;\ndefault:\n    throw new Error(\"Unknown type: \" + type);\n\n// after\ncase \"int\":\ncase \"integer\":\ncase \"double\":\n    base = \"number\";\n    break;\ndefault:\n    throw new Error(\"Unknown type: \" + type);","handlingStrategy":"validation","validationCode":"const KNOWN_TYPES = new Set([\"string\", \"boolean\", \"int\", \"number\", \"any\"]);\nfunction assertAllTypesKnown(spec: { properties: { type: string }[] }) {\n  for (const p of spec.properties) {\n    if (!KNOWN_TYPES.has(p.type)) throw new Error(`spec uses unmapped type: ${p.type}`);\n  }\n}","typeGuard":"function isKnownType(type: string): type is \"string\" | \"boolean\" | \"int\" {\n  return [\"string\", \"boolean\", \"int\"].includes(type);\n}","tryCatchPattern":"try {\n  generateOptionsTypes(spec, source);\n} catch (e) {\n  const m = /Unknown type: (.+)/.exec(String(e));\n  if (m) console.error(`Add a mapping for '${m[1]}' to the type table`);\n  throw e;\n}","preventionTips":["When a schema upgrades new types, extend the switch's mapping table in the same PR","Validate input specs against the metaschema before generation","Cover the type-mapping function with exhaustive unit tests for every schema primitive"],"tags":["codegen","schema","typescript","unmapped-type"],"backgroundTag":"unknown-schema-type","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}