Skip to content

[ContentUnderstanding] RecordMergePatchUpdate leaks as public model name #45409

@yungshinlintw

Description

@yungshinlintw

Bug: RecordMergePatchUpdate leaks as public model name in Python SDK

Package

azure-ai-contentunderstanding

Description

The Python SDK exposes RecordMergePatchUpdate as a public model in azure.ai.contentunderstanding.models. This is a synthetic type generated by the TypeSpec Python emitter from MergePatchUpdate<ContentUnderstandingDefaults> — it has no meaningful semantics and should not be part of the public API.

Root Cause

The TypeSpec route definition uses:

updateDefaults is Foundations.Operation<
    MergePatchUpdate<ContentUnderstandingDefaults>,
    ContentUnderstandingDefaults,
    ServiceTraits
>;

ContentUnderstandingDefaults has a single field modelDeployments: Record<string>. The Python emitter generates a synthetic model RecordMergePatchUpdate for the merge-patch body type, which is effectively just Dict[str, str].

What the user sees

  1. In models/__init__.py: RecordMergePatchUpdate is exported as a public type
  2. In method signatures (generated _operations.py):
    def update_defaults(
        self,
        *,
        model_deployments: Optional[RecordMergePatchUpdate] = None,
        ...
    )
  3. In docstrings: :paramtype model_deployments: ~azure.ai.contentunderstanding.models.RecordMergePatchUpdate
  4. In _models.py: An empty class with no fields:
    class RecordMergePatchUpdate(_Model):
        """RecordMergePatchUpdate."""

Current Workaround

In models/_patch.py, we alias it to Dict[str, str]:

RecordMergePatchUpdate = Dict[str, str]

This makes it work at runtime, but the name still appears in IDE tooltips, documentation, and APIView.

Expected Behavior

The emitter should resolve MergePatchUpdate<T> where T has a single Record<string> field to Dict[str, str] directly, rather than generating a synthetic model class. At minimum, the generated method signatures should use Dict[str, str] instead of RecordMergePatchUpdate.

Affected Files (generated)

  • azure/ai/contentunderstanding/_operations/_operations.py — sync method signatures and docstrings
  • azure/ai/contentunderstanding/aio/_operations/_operations.py — async method signatures and docstrings
  • azure/ai/contentunderstanding/models/_models.py — empty model class definition

Environment

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-triageWorkflow: This is a new issue that needs to be triaged to the appropriate team.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions