Skip to content

fix: keep generated client compatible with FastAPI 0.141 and pin HpcRun wire format - #149

Merged
jcschaff merged 2 commits into
mainfrom
chore/fastapi-141-client-compat
Sep 9, 2026
Merged

jcschaff merged 2 commits into
mainfrom
chore/fastapi-141-client-compat

Conversation

@jcschaff

@jcschaff jcschaff commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #127 (FastAPI 0.116 → 0.141).

Problem. FastAPI ≥ 0.141 emits UploadFile schemas as {type: string, contentMediaType: application/octet-stream} instead of {type: string, format: binary}. The pinned client generator, openapi-python-client 0.29.1, is the latest release and only recognises format: binary as a file upload (upstream fix is still open: openapi-generators/openapi-python-client#1418). Regenerating compose-api-client from the new spec would have turned every upload parameter into a plain str, breaking pbest's run-simulation path.

Changes

  • compose_api/api/openapi_spec.py — post-process the spec after get_openapi() and normalise octet-stream string schemas back to format: binary. Ten lines, documented as temporary, delete once upstream ships contentMediaType support.
  • Regenerated compose_api/api/spec/openapi_3_1_0_generated.yaml and the in-repo client. The spec had been stale since the 0.4.0 models (singularity_defcontainer_def, new ContainerizationEngine enum, ValidationError.input/ctx). Upload fields in the regenerated client are still typed File.
  • New tests/api/test_hpc_run_serialization.py + tests/fixtures/resources/hpc_run_response.json. Inserts a simulator, simulation and HpcRun via the DB services, fetches /results/simulation/status through ASGITransport, and compares the JSON body (values and key order) to the fixture. This pins the wire format pbest parses across FastAPI 0.130's switch to pydantic-core serialisation.

Not done here: $LIB_DIR (the separate compose-api-client repo) was not regenerated; that is part of the four-step client release.

Verification

  • New test passes against FastAPI 0.141.1 (project lock)
  • Same test passes against FastAPI 0.116.2 in a scratch env — wire format unchanged across the upgrade
  • make check clean (pre-commit, mypy --strict, deptry)
  • Non-HPC suite: 9 passed, 16 skipped
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_018TgVbCXXWAWhNjtKTzrxvN

jcschaff and others added 2 commits September 8, 2026 23:00
…un wire format

FastAPI >= 0.141 describes UploadFile fields with
`contentMediaType: application/octet-stream` instead of `format: binary`.
The pinned generator (openapi-python-client 0.29.1, the latest release) only
recognises `format: binary` as a file upload; upstream support is still an
open PR (openapi-generators/openapi-python-client#1418). Regenerating the
client from the new spec would have turned every upload parameter into a plain
`str` and broken pbest.

- openapi_spec.py: normalise octet-stream string schemas back to
  `format: binary` after `get_openapi()`, so the generator keeps emitting
  `File` types. Remove once upstream ships contentMediaType support.
- Regenerate the OpenAPI spec (it had been stale since the 0.4.0 models:
  container_def rename, ContainerizationEngine enum, ValidationError
  input/ctx) and the in-repo client. Upload fields are still typed `File`.
- Add tests/api/test_hpc_run_serialization.py: inserts a simulator,
  simulation and HpcRun, fetches /results/simulation/status through the ASGI
  transport, and compares the JSON body to a checked-in fixture. FastAPI 0.130
  moved response serialisation to pydantic-core; the same test passes against
  0.116.2 and 0.141.1, so the payload pbest parses is unchanged.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018TgVbCXXWAWhNjtKTzrxvN
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018TgVbCXXWAWhNjtKTzrxvN
@jcschaff
jcschaff merged commit dba4cb4 into main Sep 9, 2026
11 checks passed
@jcschaff
jcschaff deleted the chore/fastapi-141-client-compat branch September 9, 2026 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant