{"record":{"id":"81bf833a267919b4","repo":"pulumi/pulumi","slug":"boilerplate-must-define-a-baseoptions-type","errorCode":null,"errorMessage":"Boilerplate must define a `BaseOptions` type.","messagePattern":"Boilerplate must define a `BaseOptions` type\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdk/nodejs/tools/automation/src/index.ts","lineNumber":68,"sourceCode":"\n    const specification: string = path.resolve(process.cwd(), process.argv[2]);\n    const boilerplate: string = path.resolve(process.cwd(), process.argv[3] ?? path.join(\"boilerplate\", \"testing.ts\"));\n    const output: string = path.resolve(process.cwd(), process.argv[4] ?? \"output\");\n\n    const spec: Structure = JSON.parse(fs.readFileSync(specification, \"utf-8\")) as Structure;\n    fs.mkdirSync(output, { recursive: true });\n\n    const index: string = path.join(output, \"index.ts\");\n    const project: Project = new Project({});\n\n    const source: SourceFile = project.createSourceFile(index, fs.readFileSync(boilerplate, \"utf-8\"), {\n        overwrite: true,\n    });\n\n    const baseOptionsType = source.getTypeAlias(\"BaseOptions\");\n\n    if (!baseOptionsType) {\n        throw new Error(\"Boilerplate must define a `BaseOptions` type.\");\n    }\n\n    const container: ClassDeclaration | undefined = source.getClass(\"API\");\n\n    if (!container) {\n        throw new Error(\"Boilerplate must define an `API` class.\");\n    }\n\n    generateOptionsTypes(spec, source);\n    generateCommands(spec, container, 'ReturnType<API[\"__run\"]>');\n    project.saveSync();\n})();\n\n/**\n * Every command and menu may add some flags to the pool of available flags.\n * This means that, as we descend the command tree, we need to collect all the\n * flags that have been defined and add them to an options object.\n * Flags with omit: true in the spec are excluded from the options type.","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/nodejs/tools/automation/src/index.ts#L50-L86","documentation":"This error comes from a code-generation script in the Pulumi automation tools that reads a TypeScript 'boilerplate' source file using ts-morph. The script requires the boilerplate to export a type alias named `BaseOptions`, which serves as the base options type for generated CLI command option types. If the boilerplate was edited and the `BaseOptions` type alias was renamed, removed, or made non-exported, generation aborts with this error.","triggerScenarios":"Running the automation tooling's generate step (src/index.ts) against a boilerplate .ts file that contains no top-level type alias named exactly `BaseOptions` — e.g. after refactoring, renaming to `CliBaseOptions`, or deleting it.","commonSituations":"Developers refactoring the boilerplate template, removing 'unused' types flagged by linters, or renaming types during a cleanup pass; also occurrs when a new boilerplate file is swapped in that never defined `BaseOptions`.","solutions":["Add (or restore) an exported `export type BaseOptions = { ... };` type alias to the boilerplate source file","Check that the name is exactly `BaseOptions` (case-sensitive) and declared at the top level of the file","If it was intentionally renamed, update the generator at sdk/nodejs/tools/automation/src/index.ts to look up the new name"],"exampleFix":"// before (boilerplate.ts)\nexport type CliOptions = { verbose?: boolean };\n\n// after\nexport type BaseOptions = { verbose?: boolean };","handlingStrategy":"validation","validationCode":"import { Project, SourceFile } from \"ts-morph\";\nfunction hasBaseOptions(source: SourceFile): boolean {\n  return source.getTypeAlias(\"BaseOptions\") !== undefined;\n}\n// call before running the generator:\nif (!hasBaseOptions(source)) throw new Error(\"boilerplate missing BaseOptions\");","typeGuard":"function isDefined<T>(v: T | undefined): v is T {\n  return v !== undefined;\n}\nconst baseOptionsType = source.getTypeAlias(\"BaseOptions\");\nif (isDefined(baseOptionsType)) { /* safe to use */ }","tryCatchPattern":"try {\n  project.saveSync();\n} catch (e) {\n  if (String(e).includes(\"BaseOptions\")) {\n    console.error(\"Boilerplate template drift: restore `export type BaseOptions`\");\n  }\n  throw e;\n}","preventionTips":["Add a unit test asserting the boilerplate exports `BaseOptions` before generation runs","Mark the `BaseOptions` declaration with a lint exemption comment so cleanup passes don't remove it","Keep boilerplate template changes code-reviewed with the generator in mind"],"tags":["codegen","typescript","boilerplate","ts-morph"],"backgroundTag":"missing-required-type-declaration","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}