Skip to content

core.exceptions

Overview

Custom exception handler and validation error classes.

Classes

compute_warnings_digest

Return a short, stable digest of a warnings mapping.

The digest is order-independent (keys are sorted) so that the same set of warnings always hashes to the same value. The client echoes this digest back in the acknowledgement header; the gate is only bypassed on an exact match, so a changed warning set produces a different digest and the user is re-prompted instead of silently committing past warnings they never saw.

Signature

compute_warnings_digest(warnings)

Parameters

NameTypeRequiredDescription
warningsyes

Source

server/vueda/core/exceptions.py:104

debug_stack_exception_handler

Custom exception handler which adds the exception class name to the response.

Signature

debug_stack_exception_handler(exc, context)

Parameters

NameTypeRequiredDescription
excyes
contextyes

Source

server/vueda/core/exceptions.py:47

gate_warnings

Withhold a write behind an explicit confirmation when warnings is non-empty.

warnings must be one of two shapes, chosen by the request path: the aggregate {field: [messages]} mapping for a single-object (detail) request, or no natural object to attribute a warning to at all, or the per-object {object_id: {field: [messages]}} mapping, one entry per warned object keyed by str(pk), for a bulk request. Use "non_field_errors" for a warning not tied to a field.

This gate only checks warnings for truthiness and digests it as opaque JSON — it does not itself validate the shape — but a custom caller that returns the aggregate shape for a bulk request breaks ModelActionForm's client-side object attribution: it groups a bulk action's warnings into one display group per object id, and only falls back to a single unkeyed group for a single-object action.

When warnings is falsy this returns immediately. Otherwise the digest from compute_warnings_digest is compared against the request's Acknowledge-Warnings header: a match means the client has already shown these exact warnings to the user and they confirmed, so the caller may proceed; anything else raises ConfirmationRequired (HTTP 409 with the warnings and digest), and the client re-submits with the digest once the user confirms.

Call this from a custom action body after serializer.is_valid(raise_exception=True) (so blocking validation errors surface as a 400 before the 409) and before any write or side effect. WarningConfirmationMixin and the @action(confirm=True) mode route through this same gate.

Signature

gate_warnings(request, warnings)

Parameters

NameTypeRequiredDescription
requestyes
warningsyes

Source

server/vueda/core/exceptions.py:133

ACKNOWLEDGE_WARNINGS_HEADER

Request header carrying the warnings digest the client acknowledges.

Source

server/vueda/core/exceptions.py

Documents matching: server v3.0.0a1.post1client v3.0.0-alpha.2