Skip to content

fix: escape identifiers in the Python type generator#1082

Open
oniani1 wants to merge 1 commit into
supabase:masterfrom
oniani1:fix/escape-python-type-generator
Open

fix: escape identifiers in the Python type generator#1082
oniani1 wants to merge 1 commit into
supabase:masterfrom
oniani1:fix/escape-python-type-generator

Conversation

@oniani1

@oniani1 oniani1 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

The Python type generator interpolates enum labels and column names into the generated source without escaping, so a name that contains a double quote, backslash, or newline produces invalid Python and can inject text into the generated module. The TypeScript template already passes every identifier through JSON.stringify. This does the same for enum Literal values and Field aliases.

Added a test that generates types for an enum label and a column name containing a double quote, and checks the output stays inside the string literal. It fails without the change and passes with it.

Closes #1081

Enum labels and column names are interpolated into the generated
Python source without escaping, so an identifier that contains a
double quote, backslash, or newline produces invalid output and can
inject arbitrary text into the module. The TypeScript template already
passes every name through JSON.stringify; do the same here for enum
Literal values and Field aliases.
@oniani1 oniani1 requested review from a team, avallete and soedirgo as code owners June 9, 2026 20:13
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.

Python type generator does not escape enum labels and column names

1 participant