Skip to content

fix(types): guard model_config so the pydantic v1 fallback keeps its config - #234

Merged
ccampbell-aai merged 3 commits into
AssemblyAI:masterfrom
Kayvan-Zahiri:fix/pydantic-v1-model-config
Sep 2, 2026
Merged

ccampbell-aai merged 3 commits into
AssemblyAI:masterfrom
Kayvan-Zahiri:fix/pydantic-v1-model-config

Conversation

@Kayvan-Zahiri

Copy link
Copy Markdown
Contributor

setup.py requires pydantic-settings only on Python >= 3.14, so a plain pip install assemblyai on 3.9 to 3.13 has no pydantic-settings. The from pydantic_settings import ... in types.py then raises ImportError and the SDK runs the pydantic.v1 fallback with pydantic_v2 = False. On that path a bare model_config = ConfigDict(...) is not config at all: pydantic v1 sees an untyped class attribute and makes it a real model field. Settings already has the if pydantic_v2: guard; two classes were missed.

ListTranscriptParameters: use_enum_values is inert, so list_transcripts sends

limit=2&status=TranscriptStatus.completed&model_config=%7B%27use_enum_values%27%3A+True%7D

instead of limit=2&status=completed.

RawTranscriptionConfig: extra="allow" is inert, so unmodeled fields are dropped. RawTranscriptionConfig(punctuate=True, x="y").dict() gave {'punctuate': True, 'model_config': {'extra': 'allow'}}.

Two regression tests, both failing before and passing after. tests/unit: 472 pass on master, 474 here, on pydantic 1.10.26 and 2.13.5. ruff 0.3.5 and mypy 1.5.1 report nothing new. Also removed the discard("model_config") line in test_domains.py that was hiding the phantom field.

🤖 Generated with Claude Code

…config

On Python < 3.14 a plain `pip install assemblyai` gets no pydantic-settings,
so types.py falls back to the `pydantic.v1` shim with pydantic_v2 = False.
There a bare `model_config = ConfigDict(...)` is not config, pydantic v1
reads it as an untyped attribute and turns it into a real model field.

ListTranscriptParameters lost use_enum_values, so list_transcripts sent
`status=TranscriptStatus.completed` plus a stray `model_config` query param.
RawTranscriptionConfig lost extra="allow", so the escape hatch for
not-yet-modeled server fields dropped them.

Apply the same `if pydantic_v2:` guard Settings already uses. Adds two
regression tests and removes the discard("model_config") workaround in
test_domains.py that was papering over the phantom field.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQughgr95y4B9H1jfaQH8o
@ccampbell-aai

Copy link
Copy Markdown
Contributor

Hey @Kayvan-Zahiri, great find and thank you for the PR! Please include a patch version bump and I'll approve.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DQughgr95y4B9H1jfaQH8o
@Kayvan-Zahiri

Copy link
Copy Markdown
Contributor Author

Bumped to 1.2.1. Patch rather than minor since this is a fix, matching how the recent PRs bump assemblyai/__version__.py in the same commit. Thanks for the quick look.

Resolves the __version__.py conflict: master moved 1.2.0 -> 1.2.3
(AssemblyAI#235, AssemblyAI#237, AssemblyAI#236) after this branch bumped to 1.2.1, so the patch
bump becomes 1.2.4.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@ccampbell-aai

Copy link
Copy Markdown
Contributor

Thanks for the fix and for bumping the version. Master moved on underneath this branch (#235, #237 and #236 took it from 1.2.0 to 1.2.3), so I merged master in and resolved the __version__.py conflict by taking the next patch, 1.2.4. Your commits are unchanged. Heads up: #236 added a CI check that now enforces a version bump on every PR.

@ccampbell-aai
ccampbell-aai merged commit 8efd3b0 into AssemblyAI:master Sep 2, 2026
8 checks passed
ccampbell-aai added a commit to gsharp-aai/assemblyai-python-sdk that referenced this pull request Sep 2, 2026
Resolves the __version__.py conflict: master moved 1.2.0 -> 1.2.5
(AssemblyAI#235, AssemblyAI#237, AssemblyAI#236, AssemblyAI#234, AssemblyAI#238) after this branch bumped to 1.3.0.
1.3.0 is still the next minor, so the branch's bump stands.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants