Errors

A call can fail because a definition is missing, a document is invalid, or the database refuses a change. The examples use the people data to show these results. Use the status and diagnostic fields to identify the failure.

Binding errors

LanguageFailure
CReturns a status. The owner that its operation names holds the diagnostic.
GoReturns *Error.
RustReturns Result<_, Error>.
ClojureThrows clojure.lang.ExceptionInfo with diagnostic data.
PythonRaises StardustError.
OdinReturns an Error beside its result.

The error record gives the fields in your language. Statuses gives the failure conditions of each operation.

error

This record describes a failure with its status and diagnostic. The binding copies the diagnostic before it releases the native owner.

FieldTypeUnitAbsent
codestrNone—
messagestrNone—
pathstr | NoneNoneNone
fieldstr | NoneNoneNone
entityint | NoneNoneNone
offsetint | NoneBytesNone
statusstrNone—

Statuses

Each status names a class of failure. The table lists codes from the binding. Native diagnostic codes can differ.

"invalid_argument"

Codes: time_out_of_range, invalid_argument, out_of_range, non_finite_number, cycle, unsupported_type, too_large, native_failure, live_children, wrong_kind, not_integral, inexact_number, missing_field, unknown_field, duplicate_field, too_deep, length_mismatch, malformed_tag, ambiguous_field, ambiguous_variant, invalid_value, hook_failed.

WhenOperations
the entity ID is outside the user entity range, max_depth is negative or above 32, or max_entities is negativeDatabase.read_entity
the text is malformed, the format is unknown or a number is outside i64 or finite f64parse
the format is unknown or the width is negativeDocument.serialize
the text is malformed, a format is unknown or the width is negativeconvert
the value has a host type with no document form (one the language's standard JSON encoder also refuses), a number outside i64 or finite f64, a decimal or time with no exact native form, a failing conversion method, or a cyclefrom_value
the node breaks the preorder rules or has an invalid kind or numberBuilder.add
a node breaks the preorder rules or has an invalid kind or numberBuilder.add_many
the builder has no root or a container is still openBuilder.seal
id is not a node of the documentDocument.read, Document.children
start is past the last node or capacity is negativeDocument.read_many
id is not an object node of the documentDocument.member, Document.members
the node is not an integer numberDocument.i64
the node is not a number or its value overflows f64Document.f64
the arguments include an undeclared macro parameterbuild_macro, expand_macro
the file is not a database, an option is invalid or selected plugins are incompatibleopen
the parameters or run options are invalidQuery.run, Mutation.run
the parameters or subscription options are invalidQuery.subscribe
max_wait is negativeSubscription.next, Database.indexes_sync
the patch is not an entity-keyed object, or a link names an ID outside the user entity rangeDatabase.merge_patch
the kind, action, revision or page limits are invalid, or the selected plan cannot run the current authored definitionDatabase.plan
the kind or the pattern is invalidDatabase.definitions
a bulk build is already in progress on the databaseDatabase.bulk_begin
no bulk build is in progressDatabase.bulk_add, Database.bulk_finish
a name is empty, the plugin has no call operation with the name, or the plugin refuses the requestDatabase.plugin_call
a name is empty, the plugin has no stream operation with the name, or the plugin refuses the requestDatabase.plugin_stream
the stream has finished or does not accept writesPluginStream.write
the stream does not support reads, or length is negativePluginStream.read
the stream does not support seeks, whence is unknown, or the position is negative or past the i64 rangePluginStream.seek
the stream has finished or has no finish stepPluginStream.finish
the token is empty or longer than 4096 bytesactivate
entity is not a user entityObjects.get, Objects.path
the parent or the name is invalid, or the parent is a fileObjects.lookup
the parent is invalid or is a fileObjects.children
the digest is not 64 hexadecimal digitsObjects.files, Objects.manifest, Objects.open
the array is empty or malformed, a name is invalid, or a parent is a fileObjects.create
the entity is a directory or invalid, the digest is malformed, or expected_revision is negativeObjects.update
the request is malformed, the destination is a file or inside the node, the kinds differ, or a replaced directory is not emptyObjects.move
the entity is invalid, the directory is not empty, or expected_revision is negativeObjects.remove
options is not an object, or an option is invalid, duplicated or unsupportedReactors.sync, Backups.sync, Sdk.sync

"invalid_json"

WhenOperations
JSON text is malformedparse, convert

"compile_failed"

WhenOperations
the expression does not compilebuild
the expansion does not compilebuild_macro
the expanded expression does not compileDatabase.expression

"evaluation_failed"

WhenOperations
the expression fails on the inputProgram.evaluate
the query fails or exceeds max_costQuery.run
the page does not renderRows.next
a page does not renderRows.pages, Rows.all_pages
a rerun of the query failed. Every later call reports this failureSubscription.next
a rerun of the query failedSubscription.events
the mutation failsMutation.run
the plugin cannot read its stored stateDatabase.plugin_call, Database.plugin_stream
stored bytes do not match their digestPluginStream.read
stored tree metadata or the manifest of a named payload is corruptedObjects.get, Objects.lookup, Objects.children, Objects.path
the stored manifest is corruptedObjects.manifest, Objects.open

"out_of_memory"

Codes: out_of_memory.

"not_found"

Codes: not_found.

WhenOperations
the object has no member with the keyDocument.member
the macro refers to an unknown macrobuild_macro, expand_macro
the parent directory is missing, or the file is missing and create is falseopen
no definition is stored at the pathDatabase.query, Database.mutation, Database.definition
no expression is stored at the pathDatabase.expression
the stored query definition was deletedQuery.run
the definition or exact historical plan revision does not existDatabase.plan
the plugin reports that the request names nothing it holdsDatabase.plugin_call, Database.plugin_stream
no object node has the entityObjects.get
the parent has no child with the name, or the parent does not existObjects.lookup
the parent does not existObjects.children
the node or one of its ancestors does not existObjects.path
no payload with the digest is publishedObjects.manifest, Objects.open
a parent does not exist or a digest is not publishedObjects.create
the file does not exist or the digest is not publishedObjects.update
the node or the destination does not existObjects.move
the node does not existObjects.remove

"locked"

WhenOperations
another process holds the lock after lock_timeoutopen

"conflict"

WhenOperations
an enabled plugin finds the database inconsistent with its copies: backups refuse diverging copies with code backup_history_divergent, naming themopen
concurrent writes prevent the commitMutation.run
an entity revision check fails or a concurrent writer prevents the commit; a revision mismatch reports the entity and expected and actual revisionsDatabase.merge_patch
the authored definition or accepted plan changed before the explicit control committedDatabase.plan
another write committed to the database during the buildDatabase.bulk_finish
the plugin's write lost to a concurrent change, or the database holds writesDatabase.plugin_call
the database holds writesDatabase.plugin_stream, PluginStream.finish, Objects.upload
the database holds writes while the plugin stores the bytesPluginStream.write
a name is already taken in its parent or appears twice, or the database holds writesObjects.create
expected_revision is stale, or the database holds writesObjects.update, Objects.remove
the name is occupied without replace, expected_revision is stale, or the database holds writesObjects.move

"invalid_definition"

WhenOperations
the macro is invalid or expands recursivelybuild_macro, expand_macro
the definition is invalidDatabase.query, Database.mutation
a macro it calls is invalid or expands recursivelyDatabase.expression
the loaded query definition is invalidQuery.run
the query or its callable definitions are invalidQuery.subscribe
the mutation selection or definition is invalidMutation.run
the patched definition is invalidDatabase.patch_definition

"schema_violation"

WhenOperations
the write breaks a schemaMutation.run

"invalid_commit_time"

WhenOperations
the #_tx commit time is not later than the last commitDatabase.merge_patch

"closed"

Codes: closed.

"rejected"

WhenOperations
a mutation target or write guard refuses the writeMutation.run
the database refuses the patch; the code and diagnostic path name the reason and keyDatabase.merge_patch
the database refuses the patch; the build has failed and later adds report the same statusDatabase.bulk_add
the database refuses a patch; an initial build publishes nothing and fallback keeps earlier commitsDatabase.bulk_finish

"unsupported"

Codes: abi_version, core_digest.

WhenOperations
found differs from the ABI version of the bindingcheck_version

"cancelled"

Codes: cancelled.

WhenOperations
the subscription is cancelled or closedSubscription.next

"timeout"

WhenOperations
max_wait passed firstDatabase.indexes_sync
the plugin's wait passed its limitDatabase.plugin_call
maxWait passed before the work finishedReactors.sync, Sdk.sync
maxWait passed before every target confirmedBackups.sync

"unavailable"

WhenOperations
an enabled plugin cannot reach what the open needs: backups refuse with backup_targets_unreachable, backup_target_unreadable or backup_objects_requiredopen
the patch sets stardust/history and no enabled plugin purges historyMutation.run, Database.merge_patch
the plugin is unknown or the database does not enable itDatabase.plugin_call, Database.plugin_stream
the database does not enable the objects pluginObjects.get, Objects.lookup, Objects.children, Objects.path, Objects.files, Objects.manifest, Objects.create, Objects.update, Objects.move, Objects.remove, Objects.upload, Objects.open
the database does not enable the reactors pluginReactors.status, Reactors.sync
the database does not enable the backups pluginBackups.status, Backups.sync
the database does not enable the sdk pluginSdk.status, Sdk.sync

"failed"

WhenOperations
the plugin's work failedDatabase.plugin_call
the plugin's work failed; status describes the failureReactors.sync, Backups.sync, Sdk.sync

"unlicensed"

Codes: unlicensed.

WhenOperations
the token is refused; the error names the reasonactivate

Refusal examples

The generator captured each result from the native library.

Describe the backup runtime

python95 B
try:
    await db.backups().status()
except stardust.StardustError as error:
    result = error
Result / 199 B
{:value {:code    "unavailable"
         :message "the plugin is not enabled"
         :path    nil
         :field   nil
         :entity  nil
         :offset  nil
         :status  "unavailable"}}

Wait until every target stored the history

python203 B
async with await stardust.parse("{maxWait {#dur PT5S}}", "dust") as sync_options:
    try:
        await db.backups().sync(sync_options)
    except stardust.StardustError as error:
        result = error
Result / 199 B
{:value {:code    "unavailable"
         :message "the plugin is not enabled"
         :path    nil
         :field   nil
         :entity  nil
         :offset  nil
         :status  "unavailable"}}

convert

edn_text holds this document:

edn13 B
"{:a 1 :a 2}"
python227 B
async with (await stardust.parse(edn_text, "edn")) as edn:
    output = (await edn.read((await edn.root()))).text
try:
    (await stardust.parse(output, "edn")).close()
except stardust.StardustError as error:
    result = error
Result / 216 B
{:value {:code    "invalid_edn"
         :message "invalid EDN (Duplicate_Key) at offset 6"
         :path    nil
         :field   nil
         :entity  nil
         :offset  6
         :status  "invalid_argument"}}

Refuse a metadata-only transaction

patch_text holds this document:

edn21 B
{:#_tx {:author "x"}}
python176 B
async with (await stardust.parse(patch_text, "edn")) as patch:
    try:
        (await db.merge_patch(patch))
    except stardust.StardustError as error:
        result = error
Result / 234 B
{:value {:code    "transaction_only"
         :message "a patch of only #_tx is refused: #_tx annotates a write"
         :path    "#_tx"
         :field   nil
         :entity  nil
         :offset  nil
         :status  "rejected"}}

Refuse a repeated commit time

future_text holds this document:

edn74 B
{:#_d  {:x 1}
 :#_tx {:stardust/committedAt #inst "2200-01-01T00:00:00Z"}}

patch_text holds this document:

edn74 B
{:#_e  {:x 2}
 :#_tx {:stardust/committedAt #inst "2200-01-01T00:00:00Z"}}
python265 B
async with (await stardust.parse(future_text, "edn")) as future, (await stardust.parse(patch_text, "edn")) as patch:
    (await db.merge_patch(future))
    try:
        (await db.merge_patch(patch))
    except stardust.StardustError as error:
        result = error
Result / 261 B
{:value {:code    "invalid_commit_time"
         :message "stardust/committedAt must be strictly newer than the latest commit time"
         :path    nil
         :field   nil
         :entity  nil
         :offset  nil
         :status  "invalid_commit_time"}}

Refuse an invalid query definition

query_text holds this document:

edn12 B
{:find [?x]}
python209 B
async with (await stardust.parse(query_text, "edn")) as definition:
    try:
        async with (await db.query(definition)):
            pass
    except stardust.StardustError as error:
        result = error
Result / 202 B
{:value {:code    "unbound_variable"
         :message "Unbound_Variable"
         :path    nil
         :field   nil
         :entity  nil
         :offset  nil
         :status  "invalid_definition"}}

Report a missing stored query

python127 B
try:
    async with (await db.query("people/missing")):
        pass
except stardust.StardustError as error:
    result = error
Result / 209 B
{:value {:code    "not_found"
         :message "no definition at this path"
         :path    "people/missing"
         :field   nil
         :entity  nil
         :offset  nil
         :status  "not_found"}}

Report a malformed byte at offset zero

malformed_text holds these bytes:

text1 B
]
python139 B
try:
    async with (await stardust.parse(malformed_text, "dust")):
        pass
except stardust.StardustError as error:
    result = error
Result / 204 B
{:value {:code    "invalid_dust"
         :message "Invalid_Syntax at offset 0"
         :path    nil
         :field   nil
         :entity  nil
         :offset  0
         :status  "invalid_argument"}}

Report malformed DUST

malformed_text holds these bytes:

text1 B
[
python139 B
try:
    async with (await stardust.parse(malformed_text, "dust")):
        pass
except stardust.StardustError as error:
    result = error
Result / 204 B
{:value {:code    "invalid_dust"
         :message "Unexpected_End at offset 2"
         :path    nil
         :field   nil
         :entity  nil
         :offset  2
         :status  "invalid_argument"}}