Skip to content

chore: escape spec-derived text in the model post-processor - #1240

Open
vdusek wants to merge 5 commits into
masterfrom
fix/escape-enum-docstrings
Open

vdusek wants to merge 5 commits into
masterfrom
fix/escape-enum-docstrings

Conversation

@vdusek

@vdusek vdusek commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

scripts/postprocess_generated_models.py wrote text from the OpenAPI spec into the generated Python source in two places without escaping or validating it:

  • convert_enums_to_literals copied each enum docstring between """. A """ in an enum description ended the string early and broke _models.py. Backslashes were not escaped either, so a literal \n in a description turned into a real line break.
  • add_camel_case_typeddicts wrote each field alias as a field name in the camelCase TypedDicts. An alias that is not a valid identifier, for example one with a hyphen, produced invalid source in _typeddicts.py.

The docstring is now escaped, and generation fails with a ValueError if the emitted literal does not read back as the original text. Generation also fails with a ValueError on an alias that is not a valid Python identifier. Regenerating from the current spec gives the same output as before.

✍️ Drafted by Claude Code

@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels Nov 18, 2026
@vdusek vdusek self-assigned this Nov 18, 2026
@codecov

codecov Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.63%. Comparing base (1c65eea) to head (59e244b).
⚠️ Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1240      +/-   ##
==========================================
- Coverage   95.67%   95.63%   -0.05%     
==========================================
  Files          65       65              
  Lines        6753     6753              
==========================================
- Hits         6461     6458       -3     
- Misses        292      295       +3     
Flag Coverage Δ
integration 90.80% <ø> (-0.11%) ⬇️
unit 91.33% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@vdusek
vdusek marked this pull request as ready for review November 18, 2026 14:05
@vdusek
vdusek requested a review from Pijukatel November 18, 2026 14:05
@vdusek vdusek changed the title chore: escape enum docstrings in the model post-processor chore: escape spec-derived text in the model post-processor Nov 18, 2026

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

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant