Skip to content

Migration 0.27x

Use when upgrading from a version older than these releases: 0.274.0, 0.272.0 and 0.270.0.

Part of the Migration guide.

No signature changes and no existing field default changes. What changes is how many links stay valid at once: issuing an account token now spends the user's other unused tokens of the same purpose.

What changes

Before, each POST /auth/password-reset/request only stacked a row in user_tokens, and every unused, unexpired token was valid at the same time. Now one per purpose is — the most recent.

It applies to ACTIVATION, PASSWORD_RESET, EMAIL_CHANGE and EMAIL_VERIFICATION, because the fix lives inside _issue_token, which all four flows funnel through.

The scope is narrow in both directions:

  • Same purpose only. Requesting a password reset does not kill a pending email change.
  • Same user only. Somebody else's token is untouched.

The old row is marked used_at rather than deleted, so the audit trail stays complete.

Why the default changed

Because the old behaviour cancelled out the user's own correct reaction. An attacker fires a reset for a victim; the victim gets a recovery email they never asked for, gets suspicious, and resets the password themselves. Without superseding, the attacker's link stayed valid until AUTH_PASSWORD_RESET_TTL_SECONDS. Measured:

AUTH_SINGLE_ACTIVE_TOKEN=True  -> attacker's link: refused (InvalidTokenException)
AUTH_SINGLE_ACTIVE_TOKEN=False -> attacker's link: STILL WORKS

What to do

In most services, nothing. It is the property nearly every provider already applies, and what the user expects.

It breaks one case: a flow that deliberately keeps several links alive at once — an invitation resent to several addresses where any of the links should work. If that is you:

AUTH_SINGLE_ACTIVE_TOKEN=false

One symptom to recognize if you do not set the flag: a user clicking an old link now gets InvalidTokenException (400, INVALID_TOKEN) instead of being let in. The right instruction in your UI is "request a new link", not "try again".

0.272.0 — the checks started seeing what was already wrong

No signature changes, no default changes. What changes is what tempest check-config reports — and a CI running --fail-level warning may start failing.

What changes

Three fixes, all in the direction of reporting more:

Check Before Now
deployment.I001 read DEBUG, which no mixin declares — never fired resolves SERVER_DEBUG, then DEBUG
database.W001 the debug exemption never applied; it warned with debug on quiet with debug on, warns with debug off
security.W004 did not exist warns when the secret still equals the default declared on its field

security.W004 is the one that changes the gate's outcome in practice. JWTSettings.JWT_SECRET defaults to exactly 32 characters, so it never tripped security.W002 — a service that never set JWT_SECRET passed clean. It does not any more.

What to do

If your CI runs the gate with warnings blocking:

tempest check-config --fail-level warning

...and it starts failing on security.W004, the failure is right: the service was signing tokens with a value published in the SDK source. Generate a real secret and put it in the environment:

tempest secrets rotate

If your service declared a DEBUG field by hand instead of composing ServerSettings, nothing changes — resolution tries SERVER_DEBUG first and falls back to DEBUG.

Two message texts changed

deployment.I001 now names the field that carried the flag (SERVER_DEBUG is enabled.), and database.W001 says while debug is off instead of while DEBUG is off. If any automation matches that text by substring, adjust it; each message's id is unchanged.

0.270.0 — PixCharge.raw uses the wire's spelling

No signature changes. What changes is the keys of a dictionary the canonical contract hands you.

What changes

PixCharge.raw always carried the provider's payload, but with a different spelling depending on the path. Measured on v0.269.0, same body, same two paths:

API      raw['paymentLinkUrl']   -> None
API      raw['payment_link_url'] -> https://openpix.com.br/pay/pl_1
webhook  raw['paymentLinkUrl']   -> https://openpix.com.br/pay/pl_1

The API path dumped without by_alias, so a declared field came out in snake_case while an undeclared one — which extra="allow" has kept since v0.259/v0.260 — held on to the wire name. The API path's raw was literally a mixture of the two spellings.

From v0.270.0 both paths use by_alias=True: the spelling is the provider's, always.

What to do

If your service reads raw for a field the specification declares, switch to the wire name:

from tempest_fastapi_sdk.integrations.payment import PixCharge


def payment_link(charge: PixCharge) -> object | None:
    """Read OpenPix's payment link out of the raw payload.

    Args:
        charge (PixCharge): The charge, in canonical shape.

    Returns:
        object | None: The link, when the provider sent one.
    """
    return charge.raw.get("paymentLinkUrl")

Anyone already reading an undeclared field (paidAt, say) changes nothing: those already arrived in the wire's spelling.

Finding the call sites

grep -rn 'raw\[\|raw\.get(' <your-service>/

Every raw lookup with a snake_case key is a candidate. The replacement is the name the provider's documentation uses.

Why the wire's spelling and not Python's

raw exists for what the contract does not model. A consumer discovers that field by reading the provider's documentation, and there it is called paymentLinkUrl. A spelling that only exists after the SDK renames it is one nobody can predict.

0.270.0 — PaymentStatus gained UNKNOWN

A new enum member. Additive: nothing that existed changed value.

What changes

A state the SDK does not classify now arrives as PaymentStatus.UNKNOWN, with the provider's string preserved in provider_status. Before, OpenPix's two paths answered opposite things and neither was true:

API      status 'CANCELLED' -> ValidationError -> 500 from your service
webhook  status 'CANCELLED' -> status=pending

What to do

If you branch exhaustively on PaymentStatus — a match with no case _, a dictionary indexed by member — add the case:

from tempest_fastapi_sdk.integrations.payment import PaymentStatusEnum, PixCharge


def describe(charge: PixCharge) -> str:
    """Describe a charge's state for a support screen.

    Args:
        charge (PixCharge): The charge, in canonical shape.

    Returns:
        str: A line a human can act on.
    """
    if charge.status is PaymentStatusEnum.UNKNOWN:
        return f"unclassified state: {charge.provider_status}"
    return charge.status.value

If you branch only on PAID/PENDING with a default arm, nothing to do — the new behaviour is strictly better: a charge that used to show up as PENDING without being one, or that failed the request outright, now identifies itself.