Repository navigation
fix(python): Fix python wire tests - #11284
Conversation
🌱 Seed Test SelectorSelect languages to run seed tests for:
How to use: Click the ⋯ menu above → "Edit" → check the boxes you want → click "Update comment". Tests will run automatically and snapshots will be committed to this PR. |
| // Fallback to base_url | ||
| return { | ||
| imports: "", | ||
| param: 'base_url="http://localhost:8080"' | ||
| }; |
There was a problem hiding this comment.
nit: this looks like unreachable code so could probably replace with assertNever(envConfig)
| const modulePath = this.getModulePath(); | ||
| return { | ||
| imports: `from ${modulePath}.environment import ${environmentClassName}`, | ||
| param: `environment=${environmentClassName}(base="http://localhost:8080")` |
There was a problem hiding this comment.
Based on what I'm seeing, for single base url environments, the environment class we're generating is not an instantiable class but an enum.Enum (e.g. SeedSingleUrlEnvironmentNoDefaultEnvironment.PRODUCTION). In that case do we expect SeedSingleUrlEnvironmentNoDefaultEnvironment(base="http://localhost:8080") to work?
# Conflicts: # generators/python/sdk/versions.yml
de43c80 to
c31f2fc
Compare
# Conflicts: # generators/python-v2/sdk/src/wire-tests/WireTestGenerator.ts # generators/python/sdk/versions.yml
…819) (#825) Interim hotfix for the v2.59.0 regression introduced by generator fern-python-sdk 4.46.9 (commit cb4feb824, PR fern-api/fern#11284), which began serializing every non-scalar multipart form field via json.dumps(jsonable_encoder(...)). List[str] fields are not scalar primitives, so they were sent as a single JSON-array string instead of repeated form fields -- causing the API to validate the whole array against per-item limits (e.g. speech_to_text keyterms -> invalid_keyword_length). Reverts the 8 list-of-primitive fields to raw values so httpx emits repeated form fields, matching generator fix 5.22.2. Object fields (labels, entity_detection, entity_redaction, webhook_metadata) keep json.dumps. Removes now-unused json / jsonable_encoder imports. This is intended to be carried across regenerations by Fern Replay and retired (`fern replay forget`) once the 4.x backport of 5.22.2 lands. Co-authored-by: Claude Opus 4.8 (1M context) <[email protected]>
Description
Fixes several bugs preventing Python SDK wire test generation from working correctly with some custom APIs. These issues caused mypy validation failures and runtime errors when running generated wire tests.
Changes Made
escapeStringin TypeInstantiation.ts to escape backslashes first, fixing double-escaping issues with JSON examples containing\"sequencesenvironment=ClientEnvironment(...)params instead of hardcodedbase_urlpytest.raises(ApiError)instead of failing on expected exceptionslist()wrapper for streaming endpoints (fileDownload, bytes, streaming) to consume iterators and trigger HTTP requests#refreshare never sent to servers)datetime.fromisoformat()compatibilityUpdates since last revision
buildEnvironmentSetup()to use a proper switch statement withassertNeverfor exhaustiveness checking (addressing review feedback)base_urldirectlyTesting
Human Review Checklist
buildEnvironmentSetup()handles all environment types (null, singleBaseUrl, multipleBaseUrls)base_urldirectly (since they're enums, not instantiable)Link to Devin run: https://app.devin.ai/sessions/ff265874ce2541d7b594fc06b67568ae
Requested by: [email protected] (@jsklan)