Repository navigation
Added
confirmation_token(ctoken_...) optional request field onPOST /api/v1/orders/{order_id}/payas an alternative topayment_method_token(pm_...): clients must send exactly one of the two (422 otherwise), both are included in the idempotency request fingerprint, and the in-process mock provider acceptsctoken_card_*equivalents of itspm_card_*test cards.- Every consent record (registration, consent changes, marketing changes in the profile) carries
privacy_policy_version, the version of the privacy policy in force at that moment, so that which text a person agreed to can be shown (GDPR Art. 7(1)). It is inconsent_historyofGET /api/v1/legal/consent-status; records written before 7.1.0 have it as null. - Security audit events on the
app.auditlogger: failed logins (with the reason, server side only), refresh token replays, admin requests that change something and admin routes refused to non-admins, password resets, logouts and personal data export and deletion requests. Ids only, no emails or tokens; see docs/OPERATIONS.md. - The 409
insufficient-stockresponse ofPOST /api/v1/cart/itemsandPUT /api/v1/cart/items/{product_id}now carriesavailable(units in stock) andrequested(the requested line total). rate_limit.exceededaudit event (WARNING) for every request refused with 429 by the rate limiter, with the operation (method and route template) and the limit that applied; nothing about the caller.- JSON log lines carry
stack_infowhen a record was logged withstack_info=True. BCRYPT_WAIT_TIMEOUT_SECONDS(default 10): a request that waits that long for a password hashing slot is answered 503service-overloadedwithRetry-After: 5instead of queueing without limit. Affects register, login, password reset confirmation and account deletion under a flood of password checks.- Stripe Radar early fraud warnings (
radar.early_fraud_warning.createdandradar.early_fraud_warning.updated) are recorded per payment and shown to admins:GET /api/v1/orders/{order_id}/paymentslists them under each payment'sfraud_warnings, andGET /api/v1/admin/paymentshas ahas_fraud_warningfield and ahas_fraud_warning=true|falsefilter. Nothing changes automatically: the order, its payment status and its refunds are untouched and no refund is issued. The webhook endpoint must be subscribed to the two new event types.
Upgrade notes
BCRYPT_ROUNDSabove 15 is refused at startup (it was accepted up to bcrypt's own 31). Each step doubles the cost of every login: 16 is about 5 s a hash. A deployment with a value above 15 must lower it.- The HTTP API is unchanged. Operators who traced with
OTEL_*and an image built withINSTALL_TELEMETRY=trueget no spans after the upgrade, and the build argument is ignored; remove both from the deployment.
Removed
ESSENTIAL_COOKIESandCOOKIE_CONSENT_EXPIRE_DAYSsettings: the application sets only the guest cart cookie (notsession,csrf_tokenor a consent cookie).- The
RELOADsetting. Nothing read it: uvicorn's auto-reload followsDEBUG(on in development). Setting it has no effect, as before. - OpenTelemetry tracing:
app/core/telemetry.py, thetelemetryextra, theINSTALL_TELEMETRYbuild argument of the image and the OpenTelemetry SDK, exporter and instrumentation packages (with protobuf and wrapt, which only they needed).OTEL_*variables are no longer read.opentelemetry-apistays in the lock as a dependency of FastAPI itself; without an SDK it does nothing. Logs keeprequest_idand thetrace_idof an incomingtraceparent, in the API and in Celery tasks. A single API and worker are debugged by these ids and the slow statement log; distributed tracing pays off across several services, which this project does not have. RedisService.update_cart/delete_cartandAsyncRedisService.update_cart/delete_cart, which nothing in the application called. Internal only; no API change.
Changed
- The order email sent when an order is created now says the order was received and is awaiting payment (
Order #<id> received - awaiting payment); a successful payment sends its own "payment received, order confirmed" email instead of the generic order-status-update email. POST /api/v1/orders/{order_id}/paynow creates and confirms a PaymentIntent in a single StripePaymentIntent.create(..., confirm=True)call using the attempt's provider idempotency key (no separate:confirmcall or key for new attempts). Legacyunknownattempts created before 7.1.0 that already hold an unconfirmed PaymentIntent id still complete viaconfirmwith the:confirmkey on retry.- Legal documents (
privacy-policy.md,terms-of-service.md,cookie-policy.md) moved from inline strings inapp/api/v1/legal.pyto versioned Markdown files underapp/legal/(version1.1, effective2026-11-28), overridable viaLEGAL_DOCS_DIR, and corrected outdated or inaccurate statements (removed the closed EU Online Dispute Resolution platform reference, fixed Directive 2011/83/EU Art. 13(1) refund timing and the account age wording in terms, added recipients, GDPR Chapter V transfer safeguards and Art. 18 restriction right in the privacy policy, and aligned the cookie policy with the guest cart cookie only). - Privacy policy
1.2(effective2026-12-01) adds the GDPR Art. 13(2)(e) statutory/contractual requirement and the consequences of not providing data, the Art. 13(2)(f) statement that no automated decision-making or profiling with legal effect takes place, a table tying each purpose to its legal basis, and separate retention for account data and accounting records. - Email bodies are rendered from Jinja2 HTML templates under
app/templates/email/withautoescape=TrueandStrictUndefinedviaapp/services/email/templates.py(addingjinja23.1.6), replacing f-strings and manualhtml.escapecalls inapp/services/email/messages.py. - Security headers: tighten
Permissions-Policyto the OWASP Secure Headers Project baseline (headers_add.json, 2026-11-23) and addbase-uri 'none'; form-action 'none'to the APIContent-Security-Policy(base-uri 'self'; form-action 'self'on docs pages). - Structured logging: uvicorn's own server and error lines (
UVICORN_LOG_CONFIGpassed touvicorn.run) are written as one-line JSON to stdout, andJSONFormatterkeeps non-ASCII characters unescaped (ensure_ascii=False). - The application is built by
app.main.create_app()(the module still exposesapp = create_app(), souvicorn app.main:appis unchanged), and logging is configured when the application starts, in its lifespan, not whenapp.mainis imported. A server started with--lifespan offtherefore keeps Python's default logging. - A stored cart that cannot be read (corrupt, or written in an incompatible format) is no longer lost: the next cart change keeps the old raw value under
<cart key>:unreadablewith the cart's TTL and logs a WARNING (an account cart by its account id, a guest cart without its id). It used to be replaced by an empty cart and overwritten. - PostgreSQL in Compose logs statements of 500 ms or more with their duration and SQL text, without bound values (
log_min_duration_statement=500ms,log_parameter_max_length=0); see docs/OPERATIONS.md. - Images: uv 0.13.9 in the app image (was 0.13.6); the PostgreSQL 18.6 and Redis 8.8 (8.8.4) base images on their current digests (rebuilt 2026-11-11 and 2026-11-12).
- CI: uv 0.13.9, astral-sh/setup-uv v10.4.0, Trivy 0.76.2, the service images on the new digests. The log is shorter: quiet
uv syncanduv export, no list of the expected skips in the test job, coverage tables only for files below 100%, one Trivy database download per run instead of three, without a progress bar or a table of clean packages, no build record artifact, andalembic upgrade headin the test setup prints only when it fails. The run page shows the coverage table (files below 100%), and the test job lists its tests slower than one second. - CI
docker-build: after the Trivy scan, startdocker-compose.yml(db,redis,migrate,api) inproductionmode (.env.examplewith secrets generated for the run, the Stripe provider and an https frontend, so the deployment startup checks run too) and probe/livezand/readyz.
Fixed
- The Celery worker and beat start again in the Docker image. kombu's Redis transport imports
packagingwithout declaring it, and the OpenTelemetry packages removed in this release were what installed it, so both services exited at startup withModuleNotFoundError: No module named 'packaging'(the API was not affected).packagingis now a direct dependency, and the CI compose smoke test starts the worker and beat and fails if either is restarted. POST /api/v1/orders/{order_id}/refundandPOST /api/v1/admin/payments/{payment_id}/refundnow record each refund request inrefund_attemptsbefore calling Stripe: retries with the sameIdempotency-Keyresend the exact amount sent first (reusing a key with a different amount answers 409idempotency-key-in-usewithout calling Stripe), and retries of an unresolved attempt past 23 hours are refused with 409payment-attempt-unresolvedinstead of risking a duplicate refund.- Long
Idempotency-Keyheaders (up to the 255-character API limit) no longer exceed Stripe's 255-character limit when prefixed with the flow and order id (or suffixed with:confirmon/pay):_provider_idempotency_keykeeps the plain format whenever{kind}-order-{order_id}:{client_key}:confirmfits in 255 characters and otherwise hashesclient_keywith SHA-256 ({kind}-order-{order_id}:sha256:{digest}). POST /api/v1/orders/{order_id}/payandPOST /api/v1/orders/{order_id}/checkout-sessionno longer re-send an unresolved (unknown) attempt to Stripe after 23 hours (a margin under Stripe's 24-hour idempotency-key retention), answering 409payment-attempt-unresolvedwithoutRetry-Afterso a stale retry cannot create a duplicate PaymentIntent or Checkout Session.- A stored cart (or cached catalog value) that fails validation is logged without its values: the warning names the model, the field locations and the error types only. It used to include pydantic's
input_value, so stored cart contents such as product names reached the logs. - Dispute webhook events whose
payment_intentis not found locally are retried with exponential backoff (STRIPE_EVENT_MAX_RETRIES) instead of being markedprocessed, ending infailedwith anERRORlog naming the dispute id and payment intent id if retries run out; daily reconciliation (check_payment_reconciliation) also reports local open disputes past theirevidence_due_bydeadline (dispute_past_due), and resolves the discrepancy once the dispute closes. - A
BACKEND_CORS_ORIGINSentry with an IPv6 host (for examplehttp://[::1]:3000) is kept as written. It used to get a second pair of brackets (http://[[::1]]:3000), so it never matched the browser'sOriginheader and CORS was refused for that origin. - The data deletion request (
POST /api/v1/legal/data-requestwith"request_type": "deletion") answers with the id of the deletion request again for an account that had requested data exports before. It used to return the id of the last export instead, and both confirmation emails carried that export id. - Stripe dispute lifecycle rules: inquiries (
warning_needs_response,warning_under_review) hold order fulfillment without blocking refunds (allowing a full refund to close an inquiry without a dispute fee); partial lost disputes count only the disputed amount towardOrder.payment_statusand shrink the remaining refundable amount instead of marking the whole orderrefunded; and a Stripe "late win" reversing alostdispute towonis accepted and recomputespayment_statusfrom the payment ledger without that loss.
Full test campaign: docs/reports/test-campaign-7.1.md