Skip to content

Errors

Every call of the gateway's own services (Gateway, State, Pubsub, Trigger, Config, Resources) answers the same way (openspec write-results):

  • An OK status means the call succeeded. No response carries a success flag or a status of its own. A create answers with the item's id (ScheduleTrigger → {id}).
  • A failure is a non-OK gRPC status with a message and a google.rpc.ErrorInfo detail, carried in the standard grpc-status-details-bin trailer (gRPC and gRPC-Web alike).

Gateway.Invoke and InvokeJson are the exception: they keep their envelope, which reports the proxied call's outcome. See Proxied calls.

ErrorInfo

Field Value
domain api.virtufin.com
reason one of the reasons below
metadata["field"] the request field concerned, when there is one (topic, events[1].cloudevent.source, id)
metadata["resource"] the item concerned, when there is one (a trigger id, a state key, a topic)

Reasons

The reasons are stable: a reason, once published, keeps its meaning. They are defined once per language: C# Virtufin.Api.Client.ErrorReasons, Python virtufin.api.errors.ErrorReasons, TypeScript ErrorReasons. The WorkManager answers with the same list (it reuses Virtufin.Api.Client.ErrorReasons).

Reason Status code Meaning
INVALID_FIELD INVALID_ARGUMENT A request field is missing or malformed; field names it.
ID_EXISTS ALREADY_EXISTS A given id is taken; resource is the id.
NOT_FOUND NOT_FOUND The item (a trigger, a state key, a service, a method) does not exist; resource names it.
CONFLICT ABORTED A compare-and-swap lost: an etag or create_only write, a publication fence. Read again and retry.
PARTIAL_FAILURE ABORTED A call on several items did part of its work. A further detail lists the per-item outcome (below).
DELETING FAILED_PRECONDITION The item is being deleted: its last group was removed.
NOT_MEMBER FAILED_PRECONDITION The item is not in the group named; resource is the item.
GROUP_NOT_FOUND FAILED_PRECONDITION A group named in the request does not exist; resource is the group.
CYCLE FAILED_PRECONDITION The change would make a group its own ancestor; resource is the group.
FAILED_PRECONDITION FAILED_PRECONDITION The call cannot be served in the item's present state.
RESOURCE_EXHAUSTED RESOURCE_EXHAUSTED A limit was hit: a paced publish held too long, a stalled subscriber.
OUT_OF_RANGE OUT_OF_RANGE A replay position before what the stream still holds.
UNSUPPORTED UNIMPLEMENTED The gateway does not offer this (not configured; a streaming method through unary Invoke).
UNAVAILABLE UNAVAILABLE, DEADLINE_EXCEEDED A backend, the sidecar, the broker or the scheduler did not answer. Retrying may help.
ACCESS_DENIED UNAUTHENTICATED, PERMISSION_DENIED The caller may not make this call (a missing or wrong x-api-key).
CANCELED CANCELLED The caller canceled the call.
INTERNAL INTERNAL, UNKNOWN An unexpected failure. The message is the safe text "An internal error occurred"; the gateway logs the details.

A failure the code raises without a reason of its own gets the reason its status code implies (the gateway's ErrorInfoInterceptor), so every failure has one.

Partial outcomes

A call on several items answers OK only when every item succeeded. Otherwise it fails with ABORTED, reason PARTIAL_FAILURE, and a second detail with the outcome:

Call Detail Holds
Pubsub.PublishEvents virtufin.PublishEventsFailure published, failed_indexes (indexes into the request's events; retry those)
State.DeleteBulkState virtufin.DeleteBulkStateFailure failed_keys (every other key was deleted; retry those)

Proxied calls

Invoke/InvokeJson answer OK whenever the gateway itself worked; the envelope reports the backend's outcome:

Field Value
success whether the backend call succeeded
status the backend's status code name (ALREADY_EXISTS, …), or the gateway's when it failed before reaching the backend
message the backend's message
status_details the encoded google.rpc.Status of the failure: the backend's own when it sent one (its ErrorInfo included, e.g. the WorkManager's), else one the gateway builds with the reason the status implies. Empty on success.

Reading the details

=== "C#"

```csharp
try { await client.ScheduleTriggerAsync(new ScheduleTriggerRequest { Id = "0f9a4e6b-1c2d-4e3f-8a9b-0c1d2e3f4a5b", ... }); }
catch (RpcException ex) when (ex.ErrorInfoOf() is { Reason: ErrorReasons.IdExists } error)
{
    Console.WriteLine($"{error.Resource} exists");
}
// A further detail:
var outcome = ex.DetailOf<PublishEventsFailure>();
// A proxied call: GatewayInvokeException.Error, or ApiErrors.ErrorInfoOf(response.StatusDetails).
```

=== "Python"

```python
from virtufin.api import ApiError, ErrorReasons

try:
    await client.trigger.schedule_async("t", schedule="@every 1m", id="0f9a4e6b-1c2d-4e3f-8a9b-0c1d2e3f4a5b")
except ApiError as error:          # a grpc.aio.AioRpcError
    if error.reason == ErrorReasons.ID_EXISTS:
        print(error.resource, "exists")
# error.field, error.detail(pubsub_pb2.PublishEventsFailure); Invoke failures raise ApiError too.
```

=== "TypeScript"

```ts
import { errorInfo, errorDetail, invokeErrorInfo, ErrorReasons, PublishEventsFailureSchema } from "@virtufin/api";

try { await client.scheduleTrigger("t", { id: "0f9a4e6b-1c2d-4e3f-8a9b-0c1d2e3f4a5b", schedule: "@every 1m" }); }
catch (err) {
  const info = errorInfo(err);           // undefined for a failure without details
  if (info?.reason === ErrorReasons.IdExists) console.log(`${info.resource} exists`);
}
// errorDetail(info, PublishEventsFailureSchema); invokeErrorInfo(response) for Invoke envelopes.
```