Conversation
There was a problem hiding this comment.
6 issues found across 114 files
Note: This PR contains a large number of files. cubic only reviews up to 75 files per PR, so some files may not have been reviewed.
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="samples/openapi3/client/petstore/python-httpx/petstore_api/models/uuid_with_pattern.py">
<violation number="1" location="samples/openapi3/client/petstore/python-httpx/petstore_api/models/uuid_with_pattern.py:39">
P1: Validator calls re.match on a UUID instance (value) which will raise TypeError; must convert to string or handle None/UUID before regex.</violation>
</file>
<file name="samples/openapi3/client/petstore/python/petstore_api/models/uuid_with_pattern.py">
<violation number="1" location="samples/openapi3/client/petstore/python/petstore_api/models/uuid_with_pattern.py:40">
P2: `field_validator` runs after UUID parsing, so `value` is a UUID instance and `re.match` will raise `TypeError`. Convert to string (or run the validator in `mode="before"`) to avoid runtime validation errors.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/uuid_with_pattern.py">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/uuid_with_pattern.py:40">
P2: `re.match` is called on a UUID instance, which raises `TypeError` during validation. Convert the UUID to a string before applying the regex.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-pydantic-v1/docs/UuidWithPattern.md">
<violation number="1" location="samples/openapi3/client/petstore/python-pydantic-v1/docs/UuidWithPattern.md:19">
P3: The example uses Python 2 print syntax and calls `to_json` as a class method. Under Python 3.7+, this is a SyntaxError and `to_json` should be called on the instance. Update the sample to print the instance JSON.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UuidWithPattern.md">
<violation number="1" location="samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UuidWithPattern.md:19">
P2: The example uses Python 2 print statement syntax, which is invalid in the Python 3.7+ client. Use the print() function to keep the docs runnable.</violation>
</file>
<file name="samples/openapi3/client/petstore/python-lazyImports/docs/UuidWithPattern.md">
<violation number="1" location="samples/openapi3/client/petstore/python-lazyImports/docs/UuidWithPattern.md:20">
P2: The documentation example calls `to_json` on the class, but `to_json` is an instance method. This example will fail with a missing `self` argument. Use the instance created earlier in the snippet.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| if value is None: | ||
| return value | ||
|
|
||
| if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value): |
There was a problem hiding this comment.
P1: Validator calls re.match on a UUID instance (value) which will raise TypeError; must convert to string or handle None/UUID before regex.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-httpx/petstore_api/models/uuid_with_pattern.py, line 39:
<comment>Validator calls re.match on a UUID instance (value) which will raise TypeError; must convert to string or handle None/UUID before regex.</comment>
<file context>
@@ -0,0 +1,98 @@
+ if value is None:
+ return value
+
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
+ return value
</file context>
| if value is None: | ||
| return value | ||
|
|
||
| if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value): |
There was a problem hiding this comment.
P2: field_validator runs after UUID parsing, so value is a UUID instance and re.match will raise TypeError. Convert to string (or run the validator in mode="before") to avoid runtime validation errors.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python/petstore_api/models/uuid_with_pattern.py, line 40:
<comment>`field_validator` runs after UUID parsing, so `value` is a UUID instance and `re.match` will raise `TypeError`. Convert to string (or run the validator in `mode="before"`) to avoid runtime validation errors.</comment>
<file context>
@@ -0,0 +1,111 @@
+ if value is None:
+ return value
+
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
+ return value
</file context>
| if value is None: | ||
| return value | ||
|
|
||
| if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value): |
There was a problem hiding this comment.
P2: re.match is called on a UUID instance, which raises TypeError during validation. Convert the UUID to a string before applying the regex.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-lazyImports/petstore_api/models/uuid_with_pattern.py, line 40:
<comment>`re.match` is called on a UUID instance, which raises `TypeError` during validation. Convert the UUID to a string before applying the regex.</comment>
<file context>
@@ -0,0 +1,111 @@
+ if value is None:
+ return value
+
+ if not re.match(r"^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$", value):
+ raise ValueError(r"must validate the regular expression /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$/")
+ return value
</file context>
| # create an instance of UuidWithPattern from a JSON string | ||
| uuid_with_pattern_instance = UuidWithPattern.from_json(json) | ||
| # print the JSON string representation of the object | ||
| print UuidWithPattern.to_json() |
There was a problem hiding this comment.
P2: The example uses Python 2 print statement syntax, which is invalid in the Python 3.7+ client. Use the print() function to keep the docs runnable.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-pydantic-v1-aiohttp/docs/UuidWithPattern.md, line 19:
<comment>The example uses Python 2 print statement syntax, which is invalid in the Python 3.7+ client. Use the print() function to keep the docs runnable.</comment>
<file context>
@@ -0,0 +1,28 @@
+# create an instance of UuidWithPattern from a JSON string
+uuid_with_pattern_instance = UuidWithPattern.from_json(json)
+# print the JSON string representation of the object
+print UuidWithPattern.to_json()
+
+# convert the object into a dict
</file context>
| # create an instance of UuidWithPattern from a JSON string | ||
| uuid_with_pattern_instance = UuidWithPattern.from_json(json) | ||
| # print the JSON string representation of the object | ||
| print(UuidWithPattern.to_json()) |
There was a problem hiding this comment.
P2: The documentation example calls to_json on the class, but to_json is an instance method. This example will fail with a missing self argument. Use the instance created earlier in the snippet.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-lazyImports/docs/UuidWithPattern.md, line 20:
<comment>The documentation example calls `to_json` on the class, but `to_json` is an instance method. This example will fail with a missing `self` argument. Use the instance created earlier in the snippet.</comment>
<file context>
@@ -0,0 +1,29 @@
+# create an instance of UuidWithPattern from a JSON string
+uuid_with_pattern_instance = UuidWithPattern.from_json(json)
+# print the JSON string representation of the object
+print(UuidWithPattern.to_json())
+
+# convert the object into a dict
</file context>
| # create an instance of UuidWithPattern from a JSON string | ||
| uuid_with_pattern_instance = UuidWithPattern.from_json(json) | ||
| # print the JSON string representation of the object | ||
| print UuidWithPattern.to_json() |
There was a problem hiding this comment.
P3: The example uses Python 2 print syntax and calls to_json as a class method. Under Python 3.7+, this is a SyntaxError and to_json should be called on the instance. Update the sample to print the instance JSON.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At samples/openapi3/client/petstore/python-pydantic-v1/docs/UuidWithPattern.md, line 19:
<comment>The example uses Python 2 print syntax and calls `to_json` as a class method. Under Python 3.7+, this is a SyntaxError and `to_json` should be called on the instance. Update the sample to print the instance JSON.</comment>
<file context>
@@ -0,0 +1,28 @@
+# create an instance of UuidWithPattern from a JSON string
+uuid_with_pattern_instance = UuidWithPattern.from_json(json)
+# print the JSON string representation of the object
+print UuidWithPattern.to_json()
+
+# convert the object into a dict
</file context>
a follow up PR to #22947
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Added UUID pattern validation tests to Python clients to enforce schemas with format: uuid + pattern. This improves correctness by rejecting invalid UUID v4 values.
New Features
Dependencies
Written for commit 65d99d8. Summary will update on new commits.