Repository navigation
Conversation
Every target's gen.yaml config fields may declare a ValidationRegex in config.ts. The patterns are authored as JavaScript regular expressions but the Speakeasy CLI compiles them with Go's regexp.MustCompile, so a JavaScript-only construct would panic the CLI, and a default value that fails its own pattern would reject a freshly initialised gen.yaml. Add a test over all available templates that compiles each pattern the way the CLI does and checks each default value against it.
There was a problem hiding this comment.
No issues found across 1 file
Confidence score: 5/5
- Automated review surfaced no issues in the provided summaries.
- No files require special attention.
Shadow auto-approve: would auto-approve. Adds a test guard verifying every template config ValidationRegex compiles in Go and each DefaultValue matches its pattern; no production or generated output changes, so the change is bounded and clearly beneficial.
View guided diff | Turn on auto-fix | Re-trigger cubic
Contributor
Author
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
[skip changelog]
Why
Config fields in every target's
config.tscan declare aValidationRegex. The patterns are written as JavaScript regular expressions and exported throughRegExp.source, but the Speakeasy CLI validates gen.yaml with Go: it rewrites the escaped/thatRegExp.sourceemits, then callsregexp.MustCompileon the result. Nothing in this repository checks that the two agree:(?=…)), lookbehind, or a backreference is valid inconfig.tsbut makesregexp.MustCompilepanic in the CLI for every user of that target.DefaultValuethat fails its own pattern makes a freshly initialised gen.yaml fail validation.The generator itself never reads
ValidationRegex(onlycmd/jsonschemacopies it into a JSON Schemapattern), so neither problem shows up in generation or SDK tests.Today all 269 patterns across the available templates compile in Go, and every pattern with a default accepts it. This test is a guard against regressions.
What changed
pkg/templates/config_test.go:TestConfigFieldValidationRegexesruns one subtest per template fromtemplates.GetAvailableTemplates(). For each template it loads the config fields withnewSDKbothfalseandtrue, compiles everyValidationRegexafter applying the same slash rewrite as the CLI, and asserts that everyDefaultValuematches its pattern.Per-field accept/reject cases stay in target-specific files next to it (for example
pkg/templates/config_ruby_test.gofrom #152). A default-value check cannot catch a pattern that is too strict when the default still passes.No generated output changes.
Testing
go test ./pkg/templates -run TestConfigFieldValidationRegexes -count=1: passes.^(?=O)[A-Za-z]+$): fails with a compile error naming the field;clitarget'spackageName, whose pattern contains/.make lint: passes.Public-safety check
.claude/skills/public-repo-communication/SKILL.md).git diff --check.