Error codes¶
Every failure is a
PlaceholderError with:
code: one of the codes below, anErrorCode;path: a JSON Pointer to the string that holds the placeholder (""for the value itself,/a/0/binside it), relative to the value passed toresolve;placeholder: the placeholder as written in the definition. For asyntaxerror it is input text that may be sensitive (for an unclosed@{it runs to the end of the string), so it is cut to 64 characters andstr(err)andrepr(err)leave it out; think twice before logging the attribute;message: what went wrong;reference: the reference whose value caused the error, as written (owner.settings.region, a whole namespace by its name), when one reference is at fault: its value is missing,nullor blank, of the wrong type, or its namespace is not there.Nonewhen no one reference is: a function’s own check (@{get_hour, Mars/Base}), a vault read, everycoalesceargument missing, a table function finding no value;namespaces: the namespaces the part that failed reads: the reference at fault, or the innermost call that failed with everything nested in it (not its sibling arguments), plus the namespace ofreference. Set byresolve(SQL paths included, strict or not), alike for the same placeholder. Empty for an error found before anything is read (syntax,lookup’s own arguments, a SQL position, a secret call in SQL), and fromvalidate.referenceis hidden and scrubbed asplaceholderis.
The message never contains a resolved value, so str(err) is safe to put in
a failure event or a log line.
validate returns a list of these. resolve raises
the first one; its path is a JSON Pointer into the context
(/dataset/settings/from). Map validate errors to “definition
rejected” and resolution errors to “execution failed” (§12).
Which side a failure is on:
The service:
secret_unavailable(the vault cannot be read), and failures of what the service itself put in the context. These share their codes with input problems, so tell them apart by the message, which is kept stable:Cause
Code
Message
A provider or namespace function raises
missing_valueprovider failed (<ExceptionType>)A provider returns a value that is not JSON
typea <type> is not a JSON value,value is not a finite number,object key is not a stringRetry these or report them as the service’s (a dispatcher: 503). Plain JSON objects never raise or return non-JSON, so a dispatcher whose context holds only those sees none of them but
secret_unavailable. A value the service put in the context that a function refuses (a time that is not RFC 3339, read fromrun.logical_at) isargumentnaming that value asreference: tell it from a definition error by that reference.The input: everything else: the definition, the values it reads, or the secret stored for it (
typefor a stored secret that is not UTF-8). Retrying does not help (a dispatcher: 400).
Code |
Meaning |
Example |
|---|---|---|
|
Malformed placeholder: unclosed, empty, bad name or path, a nested placeholder that is not a whole argument or is more than 16 deep, or a placeholder in an object key |
|
|
The namespace was not passed to the context (checked at resolution) |
|
|
Not in the registry |
|
|
Wrong number of arguments |
|
|
Bad argument: unknown timezone, language not |
|
|
|
|
|
An object or array embedded in text; a non-JSON value from a provider; a non-UTF-8 secret |
|
|
The |
another tenant’s path, |
|
ds-vault has no such key |
|
|
The vault cannot be read: |
|
|
Placeholder inside a SQL string, quoted identifier, or comment, or glued to another token |
|
|
|
|
|
A |
|
|
A value in the context is read again while it is being resolved, or values are read inside one another more than 64 deep |
|
from ds_common_placeholder_py_lib import ErrorCode, PlaceholderError
try:
settings = ctx.resolve("dataset.settings")
except PlaceholderError as err:
if err.code is ErrorCode.SECRET_SCOPE:
alert_security(err.path)
publish_stage_failed(code=err.code.value, message=str(err))
Who is at fault¶
A failure about a value is the fault of whoever supplies that value. Tell
them apart with reference and namespaces, never by searching the
placeholder text: a quoted literal can look like a reference, and one
placeholder can read several namespaces.
VALUE_CODES = {ErrorCode.MISSING_VALUE, ErrorCode.TYPE, ErrorCode.ARGUMENT,
ErrorCode.SECRET_SCOPE, ErrorCode.SECRET_MISSING}
def reads_only(err: PlaceholderError, namespace: str) -> bool:
"""The failure is about a value of *namespace*, and nothing else's."""
if err.code not in VALUE_CODES:
return False
if err.reference is not None:
return err.reference.partition(".")[0] == namespace
return err.namespaces == {namespace}
First take out the service’s failures:
secret_unavailable, a message startingprovider failed, and areferenceto a run fact the request should carry (run.logical_at,run.job_id, …).Then, in a pipeline,
reads_only(err, "owner")is the owner’s data at fault: the owner lacks a value or holds a wrong one. Anything else with an input code is the definition’s: a misspelt variable ismissing_valuetoo, but itsreferenceisvariables.….reads_onlypoints at the owner, but the definition may still be the one to fix. The library cannot tell these apart, so show thereferenceandpathto whoever fixes it:a misspelt owner key (
owner.settings.owner_dbid) ismissing_valueon an owner path, as if the owner lacked it;@{lookup, owner.settings.address}in SQL istype: either the owner holds an object where the definition expects text, or the definition reads the wrong key;a function’s own check on a call that reads the owner, such as a bad literal index in
@{get_value_from_dataframe, abc, a, owner.settings.rows}, has noreferenceandnamespaces{owner};a
coalescewhose value is an owner’s object, put in text or SQL (x @{coalesce, owner.settings.address, variables.v}), istypewith noreferenceand the namespaces of everycoalesceargument, so the rule calls it the definition’s.
A pipeline job runs for one owner, so any failure fails the stage request; see the pipeline section of services.