Repository navigation
Conversation
parseStringLiteral returned the source text between the quotes, so the
generated OpenAPI schema differed from the Python values:
- implicitly concatenated strings ("a " "b") kept the inner quotes and
newline, garbling multi-line descriptions;
- escape sequences were not decoded, so regex="^\\d+$" became the pattern
`^\\d+$` and coglet's schema validation rejected valid input;
- r"""...""" and u"..." literals were mis-parsed or dropped.
Decode prefixes, quotes, escapes and implicit concatenation as Python does.
This branch has not been deployed
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
parseStringLiteral(static schema generator) return the value Python gives a string literal: stripr/uprefixes and quotes, decode backslash escapes in non-raw strings, and join implicitly concatenated literals. Bytes and f-strings are still rejected.description,regexanddefaultof anInput(...).Why
parseStringLiteralreturned the source text between the quotes. The bundled.cog/openapi_schema.jsonthen differs from the predictor's real values:On
mainthis gives:description:A numeric code. "\n "Digits only.The inner quotes and indentation end up in the schema and API docs. Splitting long descriptions across lines like this is common.pattern:^\\d+$(two backslashes) instead of^\d+$. coglet validates inputs against this schema, so"123"is rejected even though the predictor's own regex accepts it.r"""..."""came back as"".."", andu"..."was not recognised. Fordefault=, that made the defaultNone.Test plan
go test ./pkg/schema/python -run 'TestParseStringLiteral|TestInputStringArgumentsUsePythonStringValues' -count=1fails onmainand passes with this changego test ./pkg/schema/... ./pkg/config/... -count=1(includes the fuzz seed corpora)go build ./...golangci-lint run ./pkg/schema/...(v2.10.1): 0 issuesI found and fixed this with an AI coding agent, and I checked the change and the test results above.