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.

Schema-constrained mutations return code schema_validation and message Schema validation failed.. Their violations list identifies each entity, schema and failed keyword. Each entry has entityPath and schemaPath arrays, such as [title] and [properties title minLength]. A token matching 0|[1-9][0-9]* within i64 is an integer, including when it names an object key. Other tokens are strings. The root is []; the empty-string key is [""]. Path arrays use decoded tokens, so / and ~ need no escaping. Constraint and actual values retain their data types. Missing required members report missingProperty instead of an actual value. Clojure uses kebab-case keys, such as :entity-path and :constraint-value.

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

stardust_diagnostic_view

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

FieldC typeUnitRangeAbsentMeaning
violationsstardust_document *NoneC type rangeAlways presentThe binding copies schema violations before the failed owner closes. Each entry contains entity and schema identities, entityPath and schemaPath arrays, and a keyword. Canonical decimal tokens within i64 are integers, including object keys. Other tokens are strings. An empty array selects the root. Entries include applicable constraintValue, actualValue, actualLength or missingProperty data. The error code remains schema_validation.
codestardust_bytesNoneC type rangeAlways present—
messagestardust_bytesNoneC type rangeAlways present—
pathstardust_bytesNoneC type rangepresent & STARDUST_DIAGNOSTIC_PATH is zeroRead this field only when present & STARDUST_DIAGNOSTIC_PATH is not zero. The call can report an empty string or zero.
fieldstardust_bytesNoneC type rangepresent & STARDUST_DIAGNOSTIC_FIELD is zeroRead this field only when present & STARDUST_DIAGNOSTIC_FIELD is not zero. The call can report an empty string or zero.
entityint64_tNoneSigned i64present & STARDUST_DIAGNOSTIC_ENTITY is zeroRead this field only when present & STARDUST_DIAGNOSTIC_ENTITY is not zero. The call can report an empty string or zero.
offsetint64_tBytesSigned i64present & STARDUST_DIAGNOSTIC_OFFSET is zeroRead this field only when present & STARDUST_DIAGNOSTIC_OFFSET is not zero. The call can report an empty string or zero.
presentint64_tNoneSigned i64Always presentPresence-bit mask: test each STARDUST_DIAGNOSTIC_* bit before you read its optional field.

Statuses

A C call returns its status. Examine a returned error owner when the operation provides one. Status-only calls have no new diagnostic.

STARDUST_INVALID_ARGUMENT

WhenOperations
the bundle, schemaPath or node is invalid or an input exceeds its limitstardust_schema_validate
the entity ID is outside the user entity range, max_depth is negative or above 32, or max_entities is negativestardust_db_read_entity
a required input or output pointer is NULL, or an input owner is not readystardust_abi_version, stardust_document_builder_create, stardust_document_root, stardust_document_count, stardust_pointer_parse, stardust_pointer_format, stardust_expr_build, stardust_expr_evaluate, stardust_db_query_open, stardust_db_mutation_open, stardust_db_expression_build, stardust_db_rows_next, stardust_db_definition_get, stardust_db_definition_patch, stardust_plugins, stardust_license
the text is malformed, the format is unknown or a number is outside i64 or finite f64stardust_parse
the format is unknown or the width is negativestardust_serialize
a node breaks the preorder rules or has an invalid kind or numberstardust_document_builder_add_many
the builder has no root or a container is still openstardust_document_builder_seal
start is past the last node or capacity is negativestardust_document_read_many
id is not an object node of the documentstardust_document_member
id is not a node of the documentstardust_document_pointer
the node is not an integer numberstardust_document_i64
the node is not a number or its value overflows f64stardust_document_f64
the arguments include an undeclared macro parameterstardust_macro_build, stardust_macro_expand
the file is not a database, an option is invalid, selected plugins are incompatible, or a plugin refuses its settings: the error carries the plugin's code (such as unknown_plugin_setting), the plugin's name as its path and the setting at fault as its field (nested settings as dotted member names, ambiguous when a name holds a dot)stardust_db_open
the parameters or run options are invalidstardust_db_query_run
the parameters or subscription options are invalidstardust_db_query_subscribe
max_wait is negativestardust_db_subscription_next, stardust_db_indexes_sync
the parameters or run options are invalid, or a required parameter has no valuestardust_db_mutation_run
the patch is not an entity-keyed object, or a link names an ID outside the user entity rangestardust_db_merge_patch
the kind, action, revision or page limits are invalid, or the selected plan cannot run the current authored definitionstardust_db_plan
the kind or the pattern is invalidstardust_db_definition_list
a bulk build is already in progress on the databasestardust_db_bulk_begin
no bulk build is in progressstardust_db_bulk_add, stardust_db_bulk_finish
a name is empty, the plugin has no call operation with the name, or the plugin refuses the requeststardust_db_plugin_call
a name is empty, the plugin has no stream operation with the name, or the plugin refuses the requeststardust_db_plugin_stream_open
the stream has finished or does not accept writesstardust_db_plugin_stream_write
the stream does not support reads, or length is negativestardust_db_plugin_stream_read
the stream does not support seeks, whence is unknown, or the position is negative or past the i64 rangestardust_db_plugin_stream_seek
the stream has finished or has no finish stepstardust_db_plugin_stream_finish
the token is empty or longer than 4096 bytesstardust_activate

STARDUST_INVALID_JSON

WhenOperations
JSON text is malformedstardust_parse

STARDUST_COMPILE_FAILED

WhenOperations
the expression does not compilestardust_expr_build
the expansion does not compilestardust_macro_build
the expanded expression does not compilestardust_db_expression_build

STARDUST_EVALUATION_FAILED

WhenOperations
the validation work limit is exceededstardust_schema_validate
the expression fails on the inputstardust_expr_evaluate
the query fails, exceeds max_cost or exceeds its automatic work limitstardust_db_query_run
the page does not renderstardust_db_rows_next
a rerun of the query failed. Every later call reports this failurestardust_db_subscription_next
the mutation failsstardust_db_mutation_run
the plugin cannot read its stored statestardust_db_plugin_call, stardust_db_plugin_stream_open
stored bytes do not match their digeststardust_db_plugin_stream_read

STARDUST_OUT_OF_MEMORY

STARDUST_NOT_FOUND

WhenOperations
the object has no member with the keystardust_document_member
the macro refers to an unknown macrostardust_macro_build, stardust_macro_expand
the parent directory is missing, or the file is missing and create is falsestardust_db_open
no definition is stored at the pathstardust_db_query_open, stardust_db_mutation_open, stardust_db_definition_get
no expression is stored at the pathstardust_db_expression_build
the stored query definition was deletedstardust_db_query_run
the definition or exact historical plan revision does not existstardust_db_plan
the plugin reports that the request names nothing it holdsstardust_db_plugin_call, stardust_db_plugin_stream_open

STARDUST_LOCKED

WhenOperations
another process holds the lock after lock_timeoutstardust_db_open

STARDUST_CONFLICT

WhenOperations
an enabled plugin finds the database inconsistent with its copies: backups refuse diverging copies with code backup_history_divergent, naming themstardust_db_open
concurrent writes prevent the commitstardust_db_mutation_run
an entity revision check fails or a concurrent writer prevents the commit; a revision mismatch reports the entity and expected and actual revisionsstardust_db_merge_patch
the authored definition or accepted plan changed before the explicit control committedstardust_db_plan
another write committed to the database during the buildstardust_db_bulk_finish
the plugin's write lost to a concurrent change, or the database holds writesstardust_db_plugin_call
the database holds writesstardust_db_plugin_stream_open, stardust_db_plugin_stream_finish
the database holds writes while the plugin stores the bytesstardust_db_plugin_stream_write

STARDUST_INVALID_DEFINITION

WhenOperations
a schema cannot compile or a reference cannot resolvestardust_schema_validate
the macro is invalid or expands recursivelystardust_macro_build, stardust_macro_expand
the definition is invalidstardust_db_query_open, stardust_db_mutation_open
a macro it calls is invalid or expands recursivelystardust_db_expression_build
the loaded query definition is invalidstardust_db_query_run
the query or its callable definitions are invalidstardust_db_query_subscribe
the mutation selection or definition is invalidstardust_db_mutation_run
the patched definition is invalidstardust_db_definition_patch

STARDUST_SCHEMA_VIOLATION

WhenOperations
the selected instance does not match the schemastardust_schema_validate
the write breaks a schemastardust_db_mutation_run

STARDUST_INVALID_COMMIT_TIME

WhenOperations
the #_tx commit time is not later than the last commitstardust_db_merge_patch

STARDUST_CLOSED

STARDUST_REJECTED

WhenOperations
a mutation target or write guard refuses the writestardust_db_mutation_run
the database refuses the patch; the code and diagnostic path name the reason and keystardust_db_merge_patch
a validator of an enabled plugin refused the definition, such as an event definition outside a mode or with a schema that does not compilestardust_db_definition_patch
the database refuses the patch; the build has failed and later adds report the same statusstardust_db_bulk_add
the database refuses a patch; an initial build publishes nothing and fallback keeps earlier commitsstardust_db_bulk_finish

STARDUST_UNSUPPORTED

WhenOperations
a selected plugin has no implementation on this platform: the filesystem plugin on Windowsstardust_db_open

STARDUST_CANCELLED

WhenOperations
the subscription is cancelled or closedstardust_db_subscription_next

STARDUST_TIMEOUT

WhenOperations
max_wait passed firststardust_db_indexes_sync
the plugin's wait passed its limitstardust_db_plugin_call

STARDUST_UNAVAILABLE

WhenOperations
an enabled plugin cannot reach what the open needs: backups refuse with backup_targets_unreachable, backup_target_unreadable or backup_objects_required; filesystem refuses with filesystem_fuse_unavailable or filesystem_mount_failed, naming the mount point; the events plugin is required when the database stores event definitions (plugin_required)stardust_db_open
the patch sets stardust/history and no enabled plugin purges historystardust_db_mutation_run, stardust_db_merge_patch
the plugin is unknown or the database does not enable itstardust_db_plugin_call, stardust_db_plugin_stream_open

STARDUST_FAILED

WhenOperations
a reactor fails; the initiating write and all derived changes are rolled backstardust_db_mutation_run, stardust_db_merge_patch
a reactor fails; the definition and all derived changes are rolled backstardust_db_definition_patch
a reactor fails while committing this patch; earlier fallback patches remain committedstardust_db_bulk_add
a reactor failed while adding a fallback patch; earlier patches remain committedstardust_db_bulk_finish
the plugin's work failedstardust_db_plugin_call

STARDUST_UNLICENSED

WhenOperations
the token is refused; the error names the reasonstardust_activate

STARDUST_INVALID_POINTER

WhenOperations
the text is not a JSON Pointer or the array is not a canonical path arraystardust_document_pointer
the text is not empty and does not start with /, or holds ~ not followed by 0 or 1stardust_pointer_parse
a token is a negative or non-integral number, an index-shaped string such as "0", or neither a number nor a stringstardust_pointer_format

Refusal examples

The generator captured each result from the native library.

convert

duplicate_text holds this document:

dust14 B
'{:a 1 :a 2}'
c638 B
stardust_document *source = NULL;
int64_t root = 0;
stardust_node_view view = {0};
int64_t written = 0;
int64_t status = stardust_parse(duplicate_text, STARDUST_DUST, &source);
if (status == STARDUST_OK) status = stardust_document_root(source, &root);
if (status == STARDUST_OK) status = stardust_document_read_many(source, root, 1, &view, &written);
if (status != STARDUST_OK) {stardust_document_release(source); return status;}
stardust_document *failed = NULL;
status = stardust_parse(view.text, STARDUST_EDN, &failed);
stardust_document_release(source);
stardust_diagnostic_view result = {0};
stardust_document_error(failed, &result);
Result / 187 B
{violations null
 code       invalid_edn
 message    invalid EDN (Duplicate_Key) at offset 6
 path       null
 field      null
 entity     null
 offset     6
 status     invalid_argument}

Refuse a metadata-only transaction

patch_text holds this document:

dust16 B
#_tx {author x}
c389 B
stardust_document *patch = NULL;
stardust_result *failed = NULL;
int64_t status = stardust_parse(patch_text, STARDUST_DUST, &patch);
if (status != STARDUST_OK) {stardust_document_release(patch); return status;}
status = stardust_db_merge_patch(db, patch, NULL, NULL, &failed);
stardust_document_release(patch);
stardust_diagnostic_view result = {0};
stardust_result_error(failed, &result);
Result / 203 B
{violations null
 code       transaction_only
 message    a patch of only #_tx is refused: #_tx annotates a write
 path       #_tx
 field      null
 entity     null
 offset     null
 status     rejected}

Refuse a repeated commit time

future_text holds this document:

dust67 B
#_d  {x 1}
#_tx {stardust/committedAt {#utc 2200-01-01T00:00:00Z}}

patch_text holds this document:

dust67 B
#_e  {x 2}
#_tx {stardust/committedAt {#utc 2200-01-01T00:00:00Z}}
c715 B
stardust_document *future = NULL;
stardust_document *patch = NULL;
stardust_result *committed = NULL;
int64_t status = stardust_parse(future_text, STARDUST_DUST, &future);
if (status == STARDUST_OK) status = stardust_parse(patch_text, STARDUST_DUST, &patch);
if (status == STARDUST_OK) status = stardust_db_merge_patch(db, future, NULL, NULL, &committed);
stardust_result_release(committed);
stardust_document_release(future);
if (status != STARDUST_OK) {stardust_document_release(patch); return status;}
stardust_result *failed = NULL;
status = stardust_db_merge_patch(db, patch, NULL, NULL, &failed);
stardust_document_release(patch);
stardust_diagnostic_view result = {0};
stardust_result_error(failed, &result);
Result / 233 B
{violations null
 code       invalid_commit_time
 message    stardust/committedAt must be strictly newer than the latest commit time
 path       null
 field      null
 entity     null
 offset     null
 status     invalid_commit_time}

Refuse an invalid query definition

definition_text holds this document:

dust10 B
find [?x]
c495 B
stardust_document *definition = NULL;
int64_t status = stardust_parse(definition_text, STARDUST_DUST, &definition);
if (status != STARDUST_OK) {stardust_document_release(definition); return status;}
stardust_db_source source = {.kind = STARDUST_SOURCE_DOCUMENT, .document = definition};
stardust_db_query *failed = NULL;
status = stardust_db_query_open(db, &source, &failed);
stardust_document_release(definition);
stardust_diagnostic_view result = {0};
stardust_db_query_error(failed, &result);
Result / 174 B
{violations null
 code       unbound_variable
 message    Unbound_Variable
 path       null
 field      null
 entity     null
 offset     null
 status     invalid_definition}

Report a missing stored query

c286 B
stardust_db_source source = {.kind = STARDUST_SOURCE_PATH, .path = {(const uint8_t *)"people/missing", 14}};
stardust_db_query *failed = NULL;
int64_t status = stardust_db_query_open(db, &source, &failed);
stardust_diagnostic_view result = {0};
stardust_db_query_error(failed, &result);
Result / 178 B
{violations null
 code       not_found
 message    no definition at this path
 path       people/missing
 field      null
 entity     null
 offset     null
 status     not_found}

Report a malformed byte at offset zero

malformed_text holds these bytes:

text1 B
]
c187 B
stardust_document *failed = NULL;
int64_t status = stardust_parse(malformed_text, STARDUST_DUST, &failed);
stardust_diagnostic_view result = {0};
stardust_document_error(failed, &result);
Result / 175 B
{violations null
 code       invalid_dust
 message    Invalid_Syntax at offset 0
 path       null
 field      null
 entity     null
 offset     0
 status     invalid_argument}

Report malformed DUST

malformed_text holds these bytes:

text1 B
[
c187 B
stardust_document *failed = NULL;
int64_t status = stardust_parse(malformed_text, STARDUST_DUST, &failed);
stardust_diagnostic_view result = {0};
stardust_document_error(failed, &result);
Result / 175 B
{violations null
 code       invalid_dust
 message    Unexpected_End at offset 2
 path       null
 field      null
 entity     null
 offset     2
 status     invalid_argument}