Repository navigation
Python: --version AUTO leaves 0.0.0-fern-placeholder in the generated User-Agent header #18206
Description
Component
SDKs
Priority
P1 - High (Strongly needed)
SDK Language(s)
Python
Bug Description
With --version AUTO (autoversion) on the hosted GitHub mode: pull-request path, the Python generator emits two different placeholder strings into src/<pkg>/core/client_wrapper.py:
"User-Agent": "phenoml/0.0.0-fern-placeholder",
"X-Fern-SDK-Version": "0.0.0.dev0",AutoVersionStep then rewrites only the Python-mapped placeholder (0.0.0.dev0), so the [fern-autoversion] commit stamps the real version into pyproject.toml, .fern/metadata.json, and X-Fern-SDK-Version, but User-Agent keeps the literal placeholder. Replay is not involved; the PR reports no conflicts.
Steps to reproduce
- Python SDK group with
github: { mode: pull-request }, autorelease, replay enabled (our config:fernapi/fern-python-sdkwithclient_class_nameandwire_tests.enabled, no customuser-agenttemplate, no globalUser-Agentheader). - Trigger a generation from a spec change.
- Inspect the
[fern-generated]commit on the opened PR:User-Agentisphenoml/0.0.0-fern-placeholderwhileX-Fern-SDK-Versionis0.0.0.dev0. - Inspect the
[fern-autoversion]commit:X-Fern-SDK-Versionbecomes e.g.18.2.0,User-Agentis stillphenoml/0.0.0-fern-placeholder.
Public example: PhenoML/phenoml-python-sdk#257, commits f554c20 ([fern-generated]) and f8de428 ([fern-autoversion]). It has recurred on every Python regeneration for us since at least 2026-08. Release 16.11.0 was published to PyPI on 2026-08-26 with User-Agent: phenoml/0.0.0-fern-placeholder before we noticed (https://github.com/phenoml/phenoml-python-sdk/blob/16.11.0/src/phenoml/core/client_wrapper.py). TypeScript and Java from the same runs are correct, since their mapped and canonical placeholders are the same string.
Expected
Every version-bearing string in the generated SDK, including User-Agent, is rewritten to the computed version.
Actual
User-Agent ships as phenoml/0.0.0-fern-placeholder unless hand-edited on the PR branch before merge.
Where it comes from (reading main)
packages/cli/generation/local-generation/local-workspace-runner/src/runGenerator.tsbuilds the IR with the unmapped placeholder:effectiveIrVersion = isAutoVersion(irVersion) ? MAGIC_VERSION : irVersion(around L148-150), and only later maps the version it hands to the generator config:mappedVersion = mapMagicVersionForLanguage(version, generatorLanguage)(around L227, used at L365).packages/cli/generation/ir-generator/src/generateIntermediateRepresentation.tsderivesplatformHeaders.userAgentfrom that IR version (${packageName}/${version}, around L629-630).- The Python generator (
generators/python/src/fern_python/generators/sdk/core_utilities/client_wrapper_generator.py) writesUser-Agentfromir.sdk_config.platform_headers.user_agentandX-Fern-SDK-Versionfrom the project config'spackage_version, so the two placeholders diverge for Python only. runLocalGenerationForWorkspace.tsalready handles this: it passesmapMagicVersionForLanguage(MAGIC_VERSION, irLanguage)as the IR version.runGenerator.tslooks like it just needs the same mapping (computegeneratorLanguagebefore building the IR and usemapMagicVersionForLanguage(MAGIC_VERSION, generatorLanguage)foreffectiveIrVersion).
Environment
- Fern-hosted generation triggered from the backend repo's CI check (
.fern/metadata.json:invokedBy: "ci",cliVersion: "5.148.3"), GitHub App push, Linux runners; not reproduced locally. - Related history: fix(cli): map magic version to PEP 440-compatible format for Python generators #13773 introduced the
0.0.0.dev0mapping for Python; fix(cli): prevent --version AUTO from corrupting generated SDK code in remote generation path #16727 / fix(cli): prevent --version AUTO from leaking literal "AUTO" into self-hosted SDK publish config #16960 touchedeffectiveIrVersionon this path.
Versions
Fern CLI version: 5.143.4 in fern.config.json; hosted run reports cliVersion 5.148.3 in .fern/metadata.json
SDK Generator versions:
- fernapi/fern-python-sdk 5.34.2 (also seen on 5.3x releases since 2026-08)
- fernapi/fern-typescript-sdk 3.98.3 (unaffected)
- fernapi/fern-java-sdk 4.23.2 (unaffected)
Workaround
On each Python regeneration PR, edit src/phenoml/core/client_wrapper.py by hand to set "User-Agent": "phenoml/<new-version>" before merging. CI does not catch it, so it is a manual pre-merge check in our release runbook.
Are you interested in contributing a fix?
No
Activity