Skip to content

Commit 34d53d0

Browse files
committed
fix(gooddata-api-client): restore null-byte regex pattern dropped by OpenAPI Generator
OpenAPI Generator v6.6.0 silently drops the \x00 literal from regex patterns in the generated Python code. The DeclarativeColumn model's `name` field has a spec pattern of `^[^\x00]*$` (reject null bytes, important for Postgres TEXT columns), but the generator produced the invalid Python regex `^[^]*$`, causing `re.PatternError: unterminated character set` at runtime. Fix the generated file and add a post-generation sed fixup to the Makefile `api-client` target so future regenerations are patched automatically. jira: TRIVIAL risk: low
1 parent 49f3490 commit 34d53d0

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

Makefile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ api-client: download
5858
rm -f schemas/gooddata-api-client.json
5959
cat schemas/gooddata-*.json | jq -S -s 'reduce .[] as $$item ({}; . * $$item) + { tags : ( reduce .[].tags as $$item (null; . + $$item) | unique_by(.name) ) }' | sed '/\u0000/d' > "schemas/gooddata-api-client.json"
6060
$(call generate_client,api)
61+
# OpenAPI Generator drops the \x00 literal from regex patterns like ^[^\x00]*$,
62+
# producing the invalid Python regex ^[^]*$. Restore the null-byte escape.
63+
find gooddata-api-client/gooddata_api_client -name '*.py' -exec \
64+
sed -i.bak 's/\^\[\^\]\*\$$/^[^\\x00]*$$/g' {} + && \
65+
find gooddata-api-client/gooddata_api_client -name '*.py.bak' -delete
6166

6267
.PHONY: download
6368
download:

gooddata-api-client/gooddata_api_client/model/declarative_column.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class DeclarativeColumn(ModelNormal):
7171
('name',): {
7272
'max_length': 255,
7373
'regex': {
74-
'pattern': r'^[^]*$', # noqa: E501
74+
'pattern': r'^[^\x00]*$', # noqa: E501
7575
},
7676
},
7777
('description',): {

0 commit comments

Comments
 (0)