Skip to content

Python codegen: quicktype mangles long type names #1125

@SteveSandersonMS

Description

@SteveSandersonMS

Problem

The Python codegen (via quicktype) produces mangled/abbreviated type names for types with long names in the runtime API schema. For example:

  • PermissionDecisionApprovedForIonApproval instead of PermissionDecisionApprovedForSessionApproval
  • PermissionDecisionApprovedForEntApproval instead of PermissionDecisionApprovedForPersistentApproval

This only affects Python — Go and C# codegen produce the correct full names from the same schema.

Root Cause

quicktype appears to truncate or abbreviate type names that exceed a certain length when generating Python code. The exact mechanism is unclear — it may be a Python-specific name shortening heuristic in quicktype, or a configurable option we're not setting.

Impact

The generated Python types don't match the runtime API schema names. This means we're shipping public APIs that have bad names we'll want to change later, which will be a breaking change. So we should resolve this soon, certainly before GA.

Possible Fixes

  1. Investigate quicktype Python options to disable name mangling/abbreviation
  2. Add a post-processing step to the Python codegen to fix known mangled names
  3. Consider an alternative Python code generator if quicktype can't be configured

Overall I've really had enough of quicktype and its unfortunate behaviors. Since we've built a pretty decent standalone codegenerator for C#, I wonder if we can factor out some sort of language-independent core from that (e.g., building an intermediate representation of all the types and methods we want to emit), and then add per-language renderers on top of that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions