Migration 0.25x¶
Use when upgrading from a version older than these releases: 0.259.0, 0.258.0, 0.257.0, 0.256.0, 0.252.0 and 0.251.0.
Part of the Migration guide.
0.259.0 — OpenPix money becomes int¶
Breaks anyone who annotated a variable with the generated model's type, or who compares a dump against an expected JSON string.
What changes¶
154 fields of the integrations/payment/openpix package stop being float:
- monetary values —
Charge.value,ChargePayload.value,ChargeRefundPayload.value,Transaction.value,SubAccount.balance, everypix*Limit, and the rest of the document's 50valuefields; - counts and day offsets —
skipandlimit,installmentsCount,dayDue,daysForDueDate,expiresIn. The pagination pair appeared 27 times as a response field (pageInfo,Pagination) and on 6 operations as a query parameter.
Woovi settles in whole centavos — the specification says so in the field's own
description on 58 numeric schemas — and typed all of it number. The visible effect is on the
wire:
from tempest_fastapi_sdk.integrations.payment.openpix import ChargePayload
ChargePayload(correlation_id="abc-1", value=1000).model_dump(
by_alias=True, mode="json", exclude_none=True
)
# up to v0.258.0: {"correlationID": "abc-1", "value": 1000.0, ...}
# from v0.259.0: {"correlationID": "abc-1", "value": 1000, ...}
19 fields stay float: basePrice (an exchange rate),
inputAmount/outputAmount on the stablecoin quote (the first is documented
as "currency unit, not cents"), rate, the rate-limit token bucket,
annualRevenue and Installment.expiration — the last two with no unit stated
in the document, which is why they were left alone.
Corrected in v0.260.0
This section originally said "18 fields", and that they were "the only ones
where the fraction is real". There were 19, and one of them was
Transaction.webhookSent[].status, described in the document itself as
"HTTP response status code of the webhook delivery attempt" — an HTTP
status code is never fractional. It became an int in v0.260.0.
What to do¶
Nothing, in most cases — an int satisfies at runtime wherever a float was
expected. Check three things:
- Your own annotations.
amount: float = charge.valueis now a type error. Change it toint. - Dump comparisons in tests.
assert dumped == {"value": 1000.0}still passes (1000 == 1000.0), but a comparison against a JSON string, or a snapshot ofmodel_dump_json(), does not. to_centsover a generated model. It still works and still validates (refusing negatives and fractions), it simply narrows nothing any more. For a raw payload — the dictionary out of the JSON, a webhook — it is still the right call.
The other half: your fields stop disappearing¶
Generated response models now use extra="allow". A field the provider returns
and the specification does not declare lands in model_extra instead of being
dropped during validation:
from tempest_fastapi_sdk.integrations.payment.openpix import Charge
charge = Charge.model_validate({"value": 1000, "wooviAddedThis": "later"})
(charge.model_extra or {})["wooviAddedThis"] # "later"
Payload models are unchanged: they keep extra="ignore", because there an
unexpected key is the caller's own typo.
Three fields that were in exactly that situation are now declared and typed:
Charge.fee, Charge.discount and Charge.value_with_discount. If you were
reading any of them through the raw HTTPClient because of this, the generated
method is now enough.
0.258.0 — log files now rotate¶
No signature breaks. What changes is what sits on disk: anyone reading
logs/info.log from outside the SDK now sees a window, not the whole history.
What changes¶
The per-level handlers were logging.FileHandler — unbounded growth. They are
now RotatingFileHandler with max_bytes=10_000_000 and backup_count=5, so
each level stops at ~60 MB (five rotated files plus the one being written), and
info.log.1, info.log.2, … appear next to the current file.
The reason already closed the reader side of this pair: the /logs router caps
reads at DEFAULT_MAX_RECORDS_PER_FILE = 20_000 records per file, added after
a service whose log directory had grown to gigabytes answered with a dead
worker. On a service that logs one line per request, running on a long-lived
host, info.log is what fills the disk — and a full disk takes down the
service along with whatever else shares the partition.
What to do¶
Nothing, in most cases. Check two things:
- A collector that follows the file by name. Filebeat, Promtail, Fluent Bit
and friends handle rotation, but a hand-rolled
tail -F, or a script that opens the file once at boot, misses the turnover. Point the pattern atinfo.log*if you need the rotated files. GET /logsshows the current window. The endpoint reads the exact names (info.log,error.log, …), so rotated files are not in the response. Longer retention is a collector's job, not the endpoint's.
If you want the old behavior¶
max_bytes=0 restores the plain FileHandler — for a host where logrotate
or a sidecar already owns retention:
Both knobs are keyword-only and independent: backup_count is only
read when rotation is on.
0.257.0 — the agent fakes rename the parameter to tools¶
Breaks callers passing chat_with_tools(..., specs=[...]) by keyword.
What changes¶
ScriptedBackend and FailingBackend exist to fake the ChatBackend /
ToolCallingBackend protocols — and satisfied neither under mypy. The protocol
names the parameter tools and accepts **kwargs; the fakes named it specs
and accepted nothing else. A protocol member is only implemented by a signature
with the same parameter name, so the opening line of the testing recipe was
a type error:
from tempest_fastapi_sdk.agents import Agent
from tempest_fastapi_sdk.agents.testing import ScriptedBackend, replies
agent = Agent(ScriptedBackend([replies("ok")]))
# up to v0.256.0:
# Argument 1 to "Agent" has incompatible type "ScriptedBackend";
# expected "ChatBackend | ToolCallingBackend" [arg-type]
What to do¶
Nothing, if you call positionally — which is what Agent does internally and
what the recipe shows. If your test calls the fake directly, by keyword:
-decision = await backend.chat_with_tools(messages, specs=specs)
+decision = await backend.chat_with_tools(messages, tools=specs)
The specs_seen attribute — where the fake records the tool names offered each
turn — did not change name.
What started compiling¶
Three annotations that rejected the argument the docs themselves told you to pass:
EventStream.response(on_disconnect=task.cancel), becauseTask.cancelreturnsbooland the annotation asked forNone;RedisIdempotencyStore(Redis.from_url(...)),RedisResponseCacheStore(...)andRedisWebAuthnChallengeStore(...), because the protocols demanded the parameter namekey/nameand aCoroutinereturn, while redis-py returns anAwaitable;require_authenticated(identity)with aFirebaseIdentity, because theTypeVarwas bound toBaseUserModel.
None of them changes runtime — they only stop demanding a workaround
(# type: ignore, cast) from anyone running a type checker.
0.256.0 — the RateLimitMiddleware 429 becomes JSON¶
Breaks clients that read the 429 body as text.
What changes¶
Up to v0.255.0 the middleware answered text/plain with the raw error_message:
It now answers the same envelope register_exception_handlers writes in every handler:
HTTP/1.1 429 Too Many Requests
content-type: application/json
retry-after: 60
{"detail": "Too many requests",
"code": "TOO_MANY_REQUESTS",
"details": {"retry_after_seconds": 60, "limit": 15}}
The reason is a contradiction inside the SDK itself: error_responses() always pointed 429 at ErrorResponseSchema, so a client generated from the OpenAPI schema broke deserializing the text -- and anyone adopting register_exception_handlers alongside the middleware ended up with two error shapes in one API.
What to do¶
- A client branching on
status === 429: nothing. The status andRetry-Afterare unchanged. - A client reading the body as text: read JSON instead, using
detailto display andcodeto branch.
// before
const message = await response.text();
// after
const { detail, code } = await response.json();
- A service that rewrote the response (a middleware subclass turning the text into an envelope) can delete the workaround:
error_messageplus the newerror_codecover it.
If you need the text back¶
There is no flag for it. The old body was incompatible with the schema the route itself documents, and keeping both shapes would keep the defect behind an option. A service that genuinely needs another format can subclass the middleware and override the response, the way it did before.
0.252.0 — SQLite :memory: gets one connection per session¶
No API break. It changes the connection topology of a :memory: database, so read this before upgrading if you rely on the old behaviour.
What changes¶
AsyncDatabaseManager("sqlite+aiosqlite:///:memory:") now builds the engine over a shared-cache in-memory database (file:<unique-name>?mode=memory&cache=shared&uri=true) with a normal pool, instead of letting SQLAlchemy pick StaticPool with a single connection. The manager holds one connection open for its lifetime, because a shared-cache database dies with its last connection.
This fixes the error introduced in v0.200.0, when the explicit BEGIN started being emitted for every SQLite engine:
Two overlapping sessions work again on :memory:, and RELEASE SAVEPOINT still is not a commit in disguise.
If you rely on a single connection¶
Pass the pool explicitly — a pool the caller names is never overridden:
from sqlalchemy.pool import StaticPool
from tempest_fastapi_sdk import AsyncDatabaseManager
db = AsyncDatabaseManager("sqlite+aiosqlite:///:memory:", poolclass=StaticPool)
That restores the previous topology, including its failure on overlapping sessions.
If you swapped :memory: for a temp file as a workaround¶
You can go back to :memory:. The workaround keeps working, so there is no rush.
0.251.0 — the Mercado Pago webhook signature now follows the provider's algorithm¶
Breaks anyone passing manifest_template= or unpacking the return of
parse_signature_header. If you only call verify_signature, nothing in
your code changes — it simply starts verifying deliveries it used to reject.
The manifest omits absent pairs, so it is no longer a template¶
The previous implementation rendered
"id:{data_id};request-id:{request_id};ts:{ts};". Mercado Pago's official
validator (mercadopago/sdk-nodejs, src/utils/webhook/index.ts, commit
99857f33) omits the pair whose value is absent. A delivery without
data.id signs request-id:...;ts:...;, while the fixed template signed
id:;request-id:...;ts:...; — a different hash, and verification that always
failed.
from tempest_fastapi_sdk.integrations.payment.mercado_pago import build_manifest
# before: DEFAULT_MANIFEST_TEMPLATE + str.format
# now: the rule, exported
build_manifest(data_id="", request_id="req-1", timestamp="1771891200")
# "request-id:req-1;ts:1771891200;"
DEFAULT_MANIFEST_TEMPLATE and the manifest_template= parameter were
removed: they existed because the algorithm was unknown, and a template
cannot express the omission rule. If you had measured a different manifest and
were passing your own, compare it against build_manifest and open an issue if
it still differs.
parse_signature_header returns an object, not a tuple¶
from tempest_fastapi_sdk.integrations.payment.mercado_pago import parse_signature_header
# before
# timestamp, digest = parse_signature_header(header)
# now
parsed = parse_signature_header("ts=1771891200,v1=abc123")
parsed.timestamp # "1771891200"
parsed.digest() # "abc123" — the first supported version
parsed.hashes # {"v1": "abc123"} — a header may carry v1 and v2
What is new¶
versions=onverify_signature, defaulting to("v1",). A provider migration tov2becomesversions=("v2", "v1"), with no release to wait for.tolerance_seconds=(andnow=, for tests), which is what makes the manifest'stswork against replay. Still opt-in, as upstream has it.- Case-insensitive header keys, whitespace-only values treated as absent, and a
non-numeric
tsrejected as a malformed header — three upstream rules that were missing.