Reference
Error codes

Error codes

fslite_core::ErrorCode is the stable, transport-independent category for every failure an fs operation can produce. fslite-server maps each code to an HTTP status; the CLI renders each code as the code field of the JSON output (with --json). Custom transports should adopt the same mapping.

The mapping is enforced by the domain_status function (opens in a new tab) in fslite-server/src/error.rs. The code_str table there hand-maintains the snake_case spelling emitted in the JSON envelope.

ErrorCodeHTTP status
InvalidPathOrName400 Bad Request
WorkspaceBoundaryViolation400 Bad Request
InvalidCursor400 Bad Request
PermissionDenied403 Forbidden
NotFound404 Not Found
AlreadyExists409 Conflict
WrongNodeType409 Conflict
DirectoryNotEmpty409 Conflict
LinkLoop409 Conflict
BrokenLink409 Conflict
QuotaExceeded409 Conflict
RevisionConflict412 Precondition Failed
InvalidRange416 Range Not Satisfiable
StorageBusy503 Service Unavailable (with Retry-After: 1)
InternalStorageFailure500 Internal Server Error

Transport-only envelopes

fslite-server adds four errors above the FileSystem layer. They do not appear in ErrorCode — they describe a transport-level problem rather than a domain failure.

VariantHTTP status
ApiError::Unauthenticated401 Unauthorized
ApiError::WorkspaceMismatch403 Forbidden
ApiError::MalformedBody400 Bad Request
ApiError::RouteNotFound404 Not Found
ApiError::MethodNotAllowed405 Method Not Allowed
ApiError::PayloadTooLarge413 Payload Too Large
ApiError::Internal500 Internal Server Error

Envelope shape

Both the domain error family and the transport error family emit the same JSON shape:

{
  "code": "not_found",
  "message": "not found",
  "details": { "subject": "/missing.txt" }
}

code is the snake_case spelling of the variant (InvalidPathOrName → invalid_path_or_name). message is safe to surface to end users. details is opaque serde_json::Value with extra context — see each code's description below.

Per-code notes

  • RevisionConflict — details carries the conflicting current revision so callers can retry or surface the conflict to a user.
  • InvalidRange — details carries { "requested": "...", "available": ... } for byte ranges.
  • QuotaExceeded — details carries the field that exceeded (max_bytes, max_nodes, max_file_bytes).
  • DirectoryNotEmpty — details may carry a small sample of child names for diagnostics.
  • StorageBusy — implies transient contention (e.g., a brief SQLite write lock); the Retry-After header is set to 1 second.
  • LinkLoop / BrokenLink — only possible when symbolic links are enabled and traversed.