ds_common_placeholder_py_lib.errors

File: errors.py Region: ds-common-placeholder-py-lib

Description

Typed errors. A message names the placeholder text and the JSON path, never a resolved value, so it is safe to put in events and logs.

Exceptions

PlaceholderError

A placeholder could not be validated or resolved.

MissingValue

Raised by a provider when a path has no value.

Classes

ErrorCode

Stable error codes. Callers map them to failure events.

Module Contents

class ds_common_placeholder_py_lib.errors.ErrorCode[source]

Bases: enum.StrEnum

Stable error codes. Callers map them to failure events.

SYNTAX = 'syntax'
UNKNOWN_NAMESPACE = 'unknown_namespace'
UNKNOWN_FUNCTION = 'unknown_function'
ARITY = 'arity'
ARGUMENT = 'argument'
MISSING_VALUE = 'missing_value'
TYPE = 'type'
SECRET_SCOPE = 'secret_scope'
SECRET_MISSING = 'secret_missing'
SECRET_UNAVAILABLE = 'secret_unavailable'
SQL_POSITION = 'sql_position'
SQL_SECRET = 'sql_secret'
PROTECTED_FIELD = 'protected_field'
CYCLE = 'cycle'
exception ds_common_placeholder_py_lib.errors.PlaceholderError(code: ErrorCode, message: str, *, path: str = '', placeholder: str | None = None, reference: str | None = None, namespaces: frozenset[str] = frozenset())[source]

Bases: Exception

A placeholder could not be validated or resolved.

Parameters:
  • code – The error code.

  • message – What went wrong. Must not contain resolved values.

  • path – JSON Pointer of the string that holds the placeholder.

  • placeholder – The placeholder text as written in the definition. For a syntax error it is input text that may be sensitive (an unclosed @{ runs to the end of the string): it is cut to 64 characters, and str() and repr() leave it out.

  • reference – The reference whose value caused the error, as written (owner.settings.region; a whole namespace is its name), when one reference is at fault: its value is missing, null or blank, of the wrong type, or the namespace is not there. None when the error is not one reference’s (a function’s own check, a vault read, every coalesce argument missing).

  • namespaces – The namespaces the part that failed reads: the reference at fault, or the innermost call that failed with everything nested in it, plus the namespace of reference. Empty for an error found before anything is read (syntax, lookup’s own arguments, a SQL position, a secret call in SQL), and from validate.

code
message
path = ''
property placeholder: str | None

The placeholder text; at most 64 characters for syntax.

reference = None
namespaces
exception ds_common_placeholder_py_lib.errors.MissingValue[source]

Bases: Exception

Raised by a provider when a path has no value.