Repository navigation
Conversation
…n gen.yaml The typescriptv2 usageSDKInitImports and mcp-typescript advancedFlags config fields declared their checks as a ValidationFunc on the field definition. Nothing reads that key: the field definitions are decoded into sdk-gen-config's SDKGenConfigField, which has no such field, so the checks never ran and malformed values were accepted. Move both checks into a target-level validateConfig, the hook the generator already runs for gen.yaml on other targets, and skip absent or null values, which templating already treats as empty.
There was a problem hiding this comment.
All reported issues were addressed across 5 files
Shadow auto-approve: would not auto-approve because issues were found.
View guided diff | Turn on auto-fix | Re-trigger cubic
…ateConfig templateUsageSDKInit resolves package || Package, import || Import and type || Type, so validate the same effective values. Add cases for capitalized and mixed-case keys, every import type, empty and non-string values, null entries, and empty advancedFlags names.
There was a problem hiding this comment.
0 issues found across 2 files (changes from recent commits).
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Moves dead per-field config validators into the target validateConfig hook so malformed usageSDKInitImports/advancedFlags now fail generation; tests and patch changeset included, valid output unchanged.
View guided diff | Turn on auto-fix | Re-trigger cubic
Generator Snapshot Testing
Snapshot results: https://github.com/speakeasy-api/openapi-generation-snapshots/issues/140#issuecomment-6427958477 Snapshot results are summarized above. Additional run context is linked for maintainers with access. |
TristanSpeakEasy
left a comment
There was a problem hiding this comment.
Looks good, moving these checks into validateConfig makes sense. Keeping the capitalised import keys and null values working avoids unnecessary breakage.
Why
Two config fields declare their gen.yaml checks as a
ValidationFuncon the field definition inconfig.ts:typescriptv2usageSDKInitImports: must be an array of objects with a non-emptypackageandimport, and an optionaltypeoftypeImport,packageImport, oraliasImport.mcp-typescriptadvancedFlags: must be an array of alphanumeric strings.Nothing reads
ValidationFunc.GetLanguageConfigFieldsdecodes the field definitions into sdk-gen-config'sSDKGenConfigField, which has no such field, so the key is dropped and neither check has ever run. Malformed values are accepted silently: ausageSDKInitImportsentry withoutimportpasses an undefined import name toaddUsageImport, and anadvancedFlagsentry such asdry-runcan never match a flag name, becausegatherMCPFlagscompares entries againstsanitizeFieldName(flag.Name).What changed
templates/templates/typescriptv2/config.ts,templates/templates/mcp-typescript/config.ts: each check moves into a target-levelvalidateConfig(cfg). This is the hookGenerator.validateConfig(pkg/generate/configuration.go) already runs on gen.yaml for the cli, go, javav2, php, pythonv2, and ruby targets; a non-empty message fails generation withgen.yaml validation error for <target>: <message>. TheValidationFunckeys are removed.usageSDKInitImportscheck resolvespackage || Package,import || Import, andtype || Typebefore validating, matchingtemplateUsageSDKInit, so entries using the capitalized keys keep generating.nullvalues are skipped. Templating already treats both as empty (templateUsageSDKInitchecksArray.isArray,gatherMCPFlagschecks truthiness), and an emptyusageSDKInitImports:oradvancedFlags:key in gen.yaml decodes tonull, which the old function would have rejected.pkg/generate/typescript_config_validation_test.go: error and success cases for both fields, including capitalized and mixed-case import keys, every import type, empty and non-string values, and empty flag names, throughGenerator.validateConfig, in the same style ascli_config_validation_test.go. That file'snewCLITestConfighelper becomesnewLanguageTestConfig(target, cfg)so both test files share it.core/typescriptv2,mcp-typescriptpatch.Behaviour change: a gen.yaml with a malformed value for either field now fails validation instead of generating. Import types other than
typeImport,packageImport, oraliasImportnow fail validation. Previously, unrecognized values silently rendered astypeImport. Generated output for valid configurations does not change, so no review SDKs are regenerated; the existing review and test configurations (advancedFlags: [loneQueryParam],usageSDKInitImports: []) pass.Testing
go test ./pkg/generate -run TestValidateConfigTypeScript -count=1: passes. With the template changes reverted, all 15 error cases fail.go test ./pkg/generate -count=1: passes.cmd/generateagainst a one-operation spec, with gen.yaml leavingtemplateVersionunset:typescriptwithusageSDKInitImports: [{package: "@acme/sdk"}]fails withgen.yaml validation error for typescript: usageSDKInitImports[0].import must be a non-empty string; addingimport: Acmegenerates.mcp-typescriptwithadvancedFlags: [dry-run]fails withgen.yaml validation error for mcp-typescript: advancedFlags[0] must contain only letters or numbers;dryRungenerates.make check-template-typescriptv2,make check-template-mcp-typescript,make lint: pass.Public-safety check
.claude/skills/public-repo-communication/SKILL.md).git diff --check.