Skip to content

Python: --version AUTO leaves 0.0.0-fern-placeholder in the generated User-Agent header #18206

Open

Description

@gavinsharp

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

  1. Python SDK group with github: { mode: pull-request }, autorelease, replay enabled (our config: fernapi/fern-python-sdk with client_class_name and wire_tests.enabled, no custom user-agent template, no global User-Agent header).
  2. Trigger a generation from a spec change.
  3. Inspect the [fern-generated] commit on the opened PR: User-Agent is phenoml/0.0.0-fern-placeholder while X-Fern-SDK-Version is 0.0.0.dev0.
  4. Inspect the [fern-autoversion] commit: X-Fern-SDK-Version becomes e.g. 18.2.0, User-Agent is still phenoml/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.ts builds 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.ts derives platformHeaders.userAgent from that IR version (${packageName}/${version}, around L629-630).
  • The Python generator (generators/python/src/fern_python/generators/sdk/core_utilities/client_wrapper_generator.py) writes User-Agent from ir.sdk_config.platform_headers.user_agent and X-Fern-SDK-Version from the project config's package_version, so the two placeholders diverge for Python only.
  • runLocalGenerationForWorkspace.ts already handles this: it passes mapMagicVersionForLanguage(MAGIC_VERSION, irLanguage) as the IR version. runGenerator.ts looks like it just needs the same mapping (compute generatorLanguage before building the IR and use mapMagicVersionForLanguage(MAGIC_VERSION, generatorLanguage) for effectiveIrVersion).

Environment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions