aeat.adapters.inbound.sanitizer._errors module

Domain errors raised by the adapters.inbound.sanitizer subpackage.

All sanitiser errors inherit from core.errors.AeatError so callers can catch the family without importing implementation details. The hierarchy mirrors the failure surfaces the sanitiser pipeline can encounter — source-parse failure, signature-present refusal, already-sanitised guard, and unhandled PII surfaces.

exception SanitizationError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: AeatError

Base error for the adapters.inbound.sanitizer subpackage.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]
exception SanitizerValidationError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: SanitizationError, ValueError

Raised when synthetic parameters or field values fail domain validation.

This error inherits from both SanitizationError and ValueError, ensuring compatibility with Pydantic’s validator contract while remaining catchable under the package’s unified error hierarchy.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]
exception SanitizerSourceParseError(message=None, *, failure=None)[source]

Bases: SanitizationError

Raised when the source PDF cannot be opened by pikepdf.

The rendered message and structured context intentionally avoid source paths, provider payloads, and QPDF/pikepdf raw diagnostics. Callers that need to report the underlying parser failure should log only the exception type at the boundary that catches it.

Parameters:
  • message (str | None)

  • failure (str | None)

Return type:

None

code: ClassVar[ErrorCode]
exception SignaturePresentError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: SanitizationError

Raised when the source PDF carries a digital signature.

Modifying a signed PDF silently invalidates the signature; the sanitiser refuses such inputs and requires the operator to escalate to human review.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]
exception AlreadySanitizedError(*, source_sha256)[source]

Bases: SanitizationError

Raised when the source SHA-256 is already in SANITIZED_SHAS.

Prevents accidental “re-sanitise an already-committed fixture”. Callers can opt out via sanitize_pdf(..., refuse_if_already_sanitized=False).

Parameters:

source_sha256 (str)

Return type:

None

code: ClassVar[ErrorCode]
exception UnknownSurfaceError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: SanitizationError

Raised when a PII surface is detected that the sanitiser does not handle.

Used for threat-model surfaces this version of the sanitiser is not yet wired to scrub (e.g. a future modelo introduces an OCProperties shape we have not characterised). The default policy is fail; callers can downgrade to a warning by toggling the relevant drop_* flag off and accepting the resulting warning.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]