Skip to content

fix(cue2openapi): unquote regex patterns - #235

Open
cvas22 wants to merge 2 commits into
ossf:mainfrom
cvas22:fix/234-unquote-patterns
Open

cvas22 wants to merge 2 commits into
ossf:mainfrom
cvas22:fix/234-unquote-patterns

Conversation

@cvas22

@cvas22 cvas22 commented Nov 21, 2026 •

Copy link
Copy Markdown

Fixes #234

The converter took patterns straight from the CUE source with strings.Trim, so CUE escapes like \\. ended up in openapi.yaml and the Email, URL and SchemaVersion patterns stopped matching valid values. This adds a small regexPattern helper that uses literal.Unquote (already used for string unions) and calls it in the seven places that read a pattern.

The new test converts the real spec package and checks each pattern against good and bad values. It fails on main and passes with the change.

@cvas22
cvas22 requested a review from a team as a code owner November 21, 2026 08:35
@cvas22 cvas22 mentioned this pull request Nov 21, 2026

@jmeridth jmeridth left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cvas22 I don't think you meant to include the exe file. Can you confirm and please remove it from the PR. Thank you. 😄

Patterns were copied from the CUE source with strings.Trim, which kept the
CUE string escapes. The Email, URL and SchemaVersion patterns in the
generated OpenAPI therefore asked for a literal backslash, so valid values
did not match. Unquote the literal with literal.Unquote instead.

Fixes ossf#234

Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>
@cvas22
cvas22 force-pushed the fix/234-unquote-patterns branch from fd238b3 to bfccf14 Compare November 23, 2026 21:31
@cvas22

cvas22 commented Nov 23, 2026

Copy link
Copy Markdown
Author

Yep, that was an accident. Removed the exe, thx for catching it.

@jmeridth
jmeridth dismissed their stale review November 24, 2026 18:58

The exe is gone from the PR, thanks.

Comment thread cmd/cue2openapi/converter.go Resolved
Signed-off-by: Srinivas Chippagiri <cvas22@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cue2openapi keeps CUE escapes in regex patterns, so Email, URL and SchemaVersion patterns are wrong in openapi.yaml

2 participants