Skip to content

0.17.0

Latest

Choose a tag to compare

@github-actions github-actions released this 19 Oct 13:17
· 5 commits to main since this release
b617cab

Highlights

  • Binary fixture files. A file:/// fixture that is not UTF-8, such as an image, a PDF or an archive, is now sent byte for byte instead of failing with a 500. It still gets the rule's status, response_headers and result headers.
    • Content type: comes from a fixed table of common binary types, the same on every supported Python version.
    • Unchanged: .j2 files and UTF-8 fixtures are rendered as before, with the same content types.
    • See Binary files. (#125)
  • FastAPI's built-in telemetry, as mockstack settings. FastAPI 0.144 added its own OpenTelemetry tracing. mockstack now keeps it off by default and exposes two options, which take effect with tracing on:
    • opentelemetry.fastapi_tracing (MOCKSTACK__OPENTELEMETRY__FASTAPI_TRACING, --opentelemetry.fastapi-tracing) adds FastAPI's request span, with mockstack's span as its child.
    • opentelemetry.fastapi_operation_spans adds FastAPI's fastapi.dependencies and fastapi.endpoint spans beneath mockstack's.
    • Each request stays a single trace, continuing an incoming traceparent. FastAPI's metrics, logs and automatic exporters stay off, and FASTAPI_OTEL_* variables are ignored. See OpenTelemetry settings. (#124)

Fixed

  • Extra traces with current FastAPI. Installed today, 0.16.1 resolves FastAPI 0.147 or later, so with tracing on every request also produced FastAPI's own spans: a separate GET /{full_path} trace, plus dependency and endpoint spans under mockstack's. They are now off unless turned on. (#124)
  • Tracing without the extra again reports "the OpenTelemetry packages are not installed", instead of "cannot be imported: No module named 'opentelemetry.exporter'". (#124)
  • With opentelemetry.capture_response_body on:
    • Binary bodies: a binary fixture or a binary upstream response is now sent intact and recorded on the span as <N bytes, not UTF-8>. Before, it made the tracing middleware fail with an unstamped 500. (#125)
    • Repeated headers such as several Set-Cookie values are all sent; only one used to survive. (#125)
    • HEAD responses: a proxied HEAD response no longer gains a wrong content-length: 0 when mockstack leaves the length out on purpose, which it does when the upstream sent none or the body is decoded. (#126)

Changed

  • Dependencies: upgraded, with new minimum versions: FastAPI 0.147, Starlette 1.9 (via FastAPI), pydantic 2.14.1, pydantic-settings 2.16, uvicorn 0.54 and, for the opentelemetry extra, OpenTelemetry 1.45.1. (#124)
  • Package counts: FastAPI now depends on the OpenTelemetry API, so a plain install has that one package too. It is 33 packages (42 with the opentelemetry extra), up from 32 (41). The extra's SDK and OTLP exporter are still loaded only with tracing on. (#124)
  • Docker: the Docker image is retired. The mockstack/mockstack image on DockerHub has not been updated since 0.7.2 and is not maintained. Install from PyPI instead: uvx mockstack, uv tool install mockstack or pip install mockstack. (#123)

Full changes: #123, #124, #125, #126