Azure / Azure/azure-sdk-for-python

[ContentUnderstanding] RecordMergePatchUpdate leaks as public model name

Open
#45,409 0 comments 0 reactions 1 assignee Claimed by @yungshinlintw View on GitHub
Dominant language
Python
Stars
5.6k
Forks
3.4k
Avg merge
1d 21h
Merged PRs (30d)
193

Description

## 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` — it has no meaningful semantics and should not be part of the public API.

### Root Cause

The TypeSpec route definition uses:
```tsp
updateDefaults is Foundations.Operation<
MergePatchUpdate,
ContentUnderstandingDefaults,
ServiceTraits
>;
```

`ContentUnderstandingDefaults` has a single field `modelDeployments: Record`. 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`):
```python
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:
```python
class RecordMergePatchUpdate(_Model):
"""RecordMergePatchUpdate."""
```

### Current Workaround

In `models/_patch.py`, we alias it to `Dict[str, str]`:
```python
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` where `T` has a single `Record` 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

- TypeSpec commit: `2b2d493e2e883fcf474b3554839d97d1b5be1604`
- Repo: `Azure/azure-sdk-for-python`, branch `cu_sdk/ga`
- PR: https://github.com/Azure/azure-sdk-for-python/pull/45092

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.