Geode follows ISO/IEC SQL error code standards for consistent error reporting across all client libraries and interfaces. This reference provides complete documentation of all error codes, their meanings, and resolution strategies.

Error Code Format

Geode uses two types of error codes:

  1. GQLSTATUS Codes: 5-character SQL-standard status codes (e.g., 00000, 42000)
  2. Internal Error Codes: Descriptive error names (e.g., ERR_OOM, ERR_FLOAT_NAN)

Error Response Structure

All error responses follow this JSON format:

{
  "status_class": "42000",
  "status": "42001",
  "message": "Undefined table: NonExistentTable",
  "details": {
    "table_name": "NonExistentTable",
    "suggestion": "Check table name spelling or create the table first"
  }
}

GQLSTATUS Codes

Success Codes

CodeClassDescriptionAction Required
00000SuccessQuery executed successfullyNone
01000WarningWarning (with successful completion)Review warning message
02000No DataQuery returned no rowsNone (expected in some cases)

Example:

-- Returns 00000 on success
CREATE (p:Person {name: 'Alice'});

-- Returns 02000 if no matches
MATCH (p:Person {name: 'NonExistent'}) RETURN p;

Client Errors (Class 0A)

CodeDescriptionCommon CausesResolution
0A000Feature not supportedUnsupported GQL feature or operationCheck GQL compliance documentation
0A001Transaction already activeBEGIN called while transaction activeCOMMIT or ROLLBACK current transaction first
0A002No active transactionCOMMIT/ROLLBACK without BEGINStart transaction with BEGIN before committing

Examples:

-- 0A001: Transaction already active
BEGIN TRANSACTION;
BEGIN TRANSACTION;  -- ERROR

-- 0A002: No active transaction
COMMIT;  -- ERROR (no transaction started)

-- Correct usage
BEGIN TRANSACTION;
CREATE (p:Person {name: 'Bob'});
COMMIT;

Data Exception (Class 22)

CodeDescriptionCommon CausesResolution
22000Data exceptionGeneral data errorSee specific code
22001String data, right truncationString exceeds maximum lengthReduce string length or increase limit
22002Null value, no indicatorNULL in non-nullable contextProvide non-null value
22003Numeric value out of rangeNumber too large/small for typeUse appropriate numeric type
22004Null value not allowedNULL where NOT NULL constraint existsProvide non-null value
22005Error in assignmentType mismatch in assignmentCheck type compatibility
22007Invalid datetime formatMalformed date/time stringUse ISO 8601 format
22008Datetime field overflowDate/time value out of valid rangeCheck date/time bounds
22012Division by zeroArithmetic division by zeroAdd zero check before division
22015Interval field overflowInterval exceeds maximumUse smaller interval
22018Invalid character valueInvalid encoding or characterCheck string encoding (UTF-8)
22019Invalid escape characterBad escape sequence in stringUse valid escape sequences
22021Character not in repertoireCharacter not supported in encodingUse supported UTF-8 characters
22023Invalid parameter valueFunction parameter invalidCheck parameter constraints
22025Invalid escape sequenceBad regex or LIKE escapeFix escape sequence
22027Trim errorInvalid TRIM specificationCheck TRIM syntax

Examples:

-- 22001: String truncation
CREATE (p:Person {name: Char('VeryLongNameThatExceedsLimit', 10)});
-- ERROR: String 'VeryLongNameThatExceedsLimit' exceeds Char(10) limit

-- 22003: Numeric out of range
RETURN SmallInt(100000);  -- ERROR: Value exceeds i16 range

-- 22007: Invalid datetime
RETURN Date('invalid-date');  -- ERROR

-- 22012: Division by zero
RETURN 10 / 0;  -- ERROR

-- Correct usage
RETURN 10 / CASE WHEN $divisor = 0 THEN 1 ELSE $divisor END;

Integrity Constraint Violation (Class 23)

CodeDescriptionCommon CausesResolution
23000Integrity constraint violationGeneral constraint violationSee specific code
23001Restrict violationForeign key constraint prevents deleteDelete dependent records first
23502Not null violationNULL value in NOT NULL columnProvide non-null value
23503Foreign key violationReferenced record doesn’t existCreate referenced record first
23505Unique violationDuplicate value in unique indexUse unique value
23514Check constraint violationValue fails CHECK constraintProvide valid value

Examples:

-- 23502: Not null violation
CREATE (p:Person {age: null});  -- ERROR if age has NOT NULL constraint

-- 23505: Unique violation
CREATE (p1:Person {email: '[email protected]'});
CREATE (p2:Person {email: '[email protected]'});  -- ERROR if email is UNIQUE

-- 23503: Foreign key violation
CREATE (o:Order {customer_id: 999});  -- ERROR if customer 999 doesn't exist

Syntax Error or Access Violation (Class 42)

CodeDescriptionCommon CausesResolution
42000Syntax error or access rule violationGeneral syntax errorCheck GQL syntax
42001Undefined objectTable, column, or function not foundVerify object names
42002Duplicate objectObject already existsUse IF NOT EXISTS or drop first
42601Syntax errorMalformed GQL queryFix query syntax
42602Invalid nameReserved keyword or invalid identifierUse quotes for identifiers
42611Invalid column definitionBad column specificationCheck column syntax
42701Duplicate columnColumn specified multiple timesRemove duplicate
42703Undefined columnColumn doesn’t existCheck column name
42704Undefined objectReferenced object not foundCreate object or fix reference
42710Duplicate objectObject name collisionUse unique name
42712Duplicate aliasAlias used multiple timesUse unique aliases
42723Duplicate functionFunction already definedDrop function or use different name
42883Undefined functionFunction not foundCheck function name and arguments
42939Reserved nameUsing reserved keywordQuote identifier or use different name
42P01Undefined tableTable doesn’t existCreate table first
42P02Undefined parameterParameter not providedSupply parameter value
42P07Duplicate tableTable already existsUse IF NOT EXISTS or different name

Examples:

-- 42001: Undefined object
MATCH (n:NonExistentLabel) RETURN n;
-- ERROR: Label 'NonExistentLabel' not found

-- 42002: Duplicate object
CREATE INDEX person_email ON Person(email);
CREATE INDEX person_email ON Person(email);  -- ERROR

-- 42601: Syntax error
MATCH (n) RETURN n WHERE n.age > 30;  -- ERROR: WHERE after RETURN

-- 42P01: Undefined table
MATCH (n:Person) WHERE n.age > 30 RETURN n;
-- ERROR if Person label doesn't exist

-- Correct: Use IF NOT EXISTS
CREATE INDEX IF NOT EXISTS person_email ON Person(email);

Insufficient Resources (Class 53)

CodeDescriptionCommon CausesResolution
53000Insufficient resourcesGeneral resource issueIncrease resources or optimize query
53100Disk fullOut of disk spaceFree disk space
53200Out of memoryInsufficient RAMIncrease memory or reduce query complexity
53300Too many connectionsConnection pool exhaustedClose unused connections or increase pool size
53400Configuration limit exceededLimit setting reachedAdjust configuration limits

Examples:

-- 53200: Out of memory
MATCH (n)-[r*]-(m)  -- ERROR: Unbounded path may exhaust memory
RETURN n, m;

-- Correct: Limit path length
MATCH (n)-[r*1..5]-(m)
WHERE n.id = 123
RETURN n, m
LIMIT 100;

System Error (Class 58)

CodeDescriptionCommon CausesResolution
58000System errorGeneral I/O errorCheck system logs
58030I/O errorDisk read/write failureCheck disk health
58P01Undefined fileFile not foundVerify file path
58P02Duplicate fileFile already existsDelete file or use different path

Internal Error (Class XX)

CodeDescriptionCommon CausesResolution
XX000Internal errorDatabase bugReport to developers with reproduction steps
XX001Data corruptedStorage corruptionRestore from backup
XX002Index corruptedIndex integrity violationRebuild index

Internal Error Codes

Memory Errors

Error CodeDescriptionContextResolution
ERR_OOMOut of memoryMemory allocation failedReduce query complexity or increase system memory
ERR_ALLOCATION_FAILEDMemory allocation errorAllocator returned errorCheck system resources

Example:

-- ERR_OOM: Large aggregation without limits
MATCH (n)-[r*]-(m)
RETURN collect(n) AS all_nodes;  -- May cause OOM

-- Solution: Add limits
MATCH (n)-[r*1..3]-(m)
WHERE n.id = 123
RETURN collect(n) AS nearby_nodes
LIMIT 1000;

Type Errors

Error CodeDescriptionContextResolution
ERR_FLOAT_NANInvalid float (NaN or Inf)Float arithmetic produced NaN/InfCheck for division by zero or invalid operations
ERR_CHAR_LENString exceeds length limitString longer than declared Char(n)Reduce string length or use Varchar/Text
ERR_DEC_DIV_ZERODecimal division by zeroDivision by zero in Decimal arithmeticAdd zero check
ERR_IP_PARSEInvalid IP addressMalformed IP address stringUse valid IPv4/IPv6 format
ERR_JSON_PARSEInvalid JSONMalformed JSON stringFix JSON syntax
ERR_RANGE_BOUNDSInvalid range boundsRange start > end or invalid inclusive/exclusiveFix range bounds

Examples:

-- ERR_FLOAT_NAN
RETURN sqrt(-1);  -- ERROR: NaN not allowed

-- ERR_CHAR_LEN
CREATE (p:Person {code: Char('TOOLONG', 5)});  -- ERROR

-- ERR_IP_PARSE
RETURN IpAddr('999.999.999.999');  -- ERROR

-- ERR_JSON_PARSE
RETURN Json('{invalid json}');  -- ERROR

-- Correct usage
RETURN IpAddr('192.168.1.1');
RETURN Json('{"valid": "json"}');

Index Errors

Error CodeDescriptionContextResolution
ERR_INDEX_CORRUPTIONIndex structure corruptedIndex integrity check failedRebuild index
ERR_INDEX_FULLIndex size limit exceededIndex too largePartition data or increase limits

Network Errors

Error CodeDescriptionContextResolution
ERR_CONNECTION_FAILEDConnection failureCannot connect to serverCheck network and server status
ERR_TIMEOUTOperation timeoutQuery or connection timed outIncrease timeout or optimize query
ERR_PROTOCOL_ERRORProtocol violationInvalid message formatUpdate client library

Transaction Errors

Error CodeDescriptionContextResolution
ERR_TRANSACTION_CONFLICTTransaction conflictConcurrent modification conflictRetry transaction
ERR_DEADLOCKDeadlock detectedCircular lock dependencyRetry transaction
ERR_SERIALIZATION_FAILURESerialization failureSSI conflict in SERIALIZABLE isolationRetry transaction

Example:

-- ERR_TRANSACTION_CONFLICT
BEGIN TRANSACTION ISOLATION LEVEL SERIALIZABLE SNAPSHOT;
-- ... operations ...
COMMIT;  -- May fail with conflict, retry needed

-- Retry logic (pseudocode)
max_retries = 3
for attempt in range(max_retries):
    try:
        execute_transaction()
        break
    except ERR_TRANSACTION_CONFLICT:
        if attempt == max_retries - 1:
            raise
        sleep(exponential_backoff(attempt))

Error Handling Best Practices

Check for Common Errors

# Python client example
from geode_client import Client, QueryError

client = Client(host="localhost", port=3141)
async with client.connection() as conn:
    try:
        page, _ = await conn.query("MATCH (p:Person) RETURN p")
    except QueryError as e:
        message = str(e)
        if message.startswith("42P01:"):
            print("Table doesn't exist - creating it")
            await conn.execute("CREATE (:Person {name: 'Alice'})")
        elif message.startswith("53200:"):
            print("Out of memory - reducing query complexity")
            page, _ = await conn.query("MATCH (p:Person) RETURN p LIMIT 100")
        else:
            raise

Retry Transient Errors

// Go client example
import "geodedb.com/geode"

func executeWithRetry(db *sql.DB, query string, maxRetries int) error {
    for i := 0; i < maxRetries; i++ {
        _, err := db.Exec(query)
        if err == nil {
            return nil
        }

        // Check if error is retryable
        if isRetryable(err) {
            time.Sleep(time.Duration(i*100) * time.Millisecond)
            continue
        }

        return err
    }
    return fmt.Errorf("max retries exceeded")
}

func isRetryable(err error) bool {
    // Transaction conflicts, deadlocks, timeouts
    statusCode := extractStatusCode(err)
    return statusCode == "ERR_TRANSACTION_CONFLICT" ||
           statusCode == "ERR_DEADLOCK" ||
           statusCode == "ERR_TIMEOUT"
}

Validate Input Data

// Rust client example
use geode_client::{Connection, Error, Result};

async fn create_person(conn: &mut Connection, name: &str, age: i32) -> Result<()> {
    // Validate before sending to database
    if name.is_empty() {
        return Err(Error::validation("Name cannot be empty"));
    }

    if age < 0 || age > 150 {
        return Err(Error::validation("Age must be 0-150"));
    }

    let query = format!("CREATE (p:Person {{name: '{}', age: {}}})", name, age);
    conn.query(&query).await?;

    Ok(())
}

Log Errors for Debugging

-- Enable detailed error logging
-- Set in server configuration
logging:
  level: 'debug'
  include_stack_traces: true
  error_details: true

Common Error Scenarios

Scenario 1: Undefined Label

Error: 42001 - Undefined object: Label 'Person' not found

Cause: Querying non-existent label

Solution:

-- Check if label exists
SHOW LABELS;

-- Create label by inserting node
CREATE (:Person {name: 'Alice'});

-- Then retry query
MATCH (p:Person) RETURN p;

Scenario 2: Unique Constraint Violation

Error: 23505 - Unique violation: email '[email protected]' already exists

Cause: Duplicate value in unique index

Solution:

-- Option 1: Use different value
CREATE (p:Person {email: '[email protected]'});

-- Option 2: Update existing record
MATCH (p:Person {email: '[email protected]'})
SET p.updated_at = timestamp();

-- Option 3: Use MERGE to update or insert
MERGE (p:Person {email: '[email protected]'})
ON CREATE SET p.created_at = timestamp()
ON MATCH SET p.updated_at = timestamp();

Scenario 3: Transaction Conflict

Error: ERR_TRANSACTION_CONFLICT - Concurrent modification detected

Cause: Two transactions modifying same data

Solution:

# Implement retry with exponential backoff
import time
from geode_client import Client, QueryError

client = Client(host="localhost", port=3141)

async def execute_with_retry(conn, query, max_retries=3):
    for attempt in range(max_retries):
        try:
            await conn.begin()
            await conn.query(query)
            await conn.commit()
            return
        except QueryError:
            await conn.rollback()
            if attempt == max_retries - 1:
                raise
            time.sleep(0.1 * (2 ** attempt))  # Exponential backoff

# async with client.connection() as conn:
#     await execute_with_retry(conn, "MATCH (n) RETURN count(n)")

Scenario 4: Query Timeout

Error: ERR_TIMEOUT - Query exceeded timeout (30000ms)

Cause: Query too complex or slow

Solution:

-- Original (slow)
MATCH (n)-[r*]-(m)
RETURN n, m;

-- Optimized
MATCH (n)-[r*1..3]-(m)
WHERE n.id = 123
RETURN n, m
LIMIT 100;

-- Or increase timeout
-- Client configuration:
-- timeout_ms: 60000

Summary

Geode provides comprehensive error reporting with:

  • GQLSTATUS Codes: ISO/IEC SQL-standard 5-character codes for interoperability
  • Internal Error Codes: Descriptive error names for specific conditions
  • Detailed Messages: Clear explanations and resolution guidance
  • Structured Errors: JSON format with context and suggestions

Use error codes to:

  1. Identify issues - Understand what went wrong
  2. Handle gracefully - Implement retry logic for transient errors
  3. Validate input - Prevent errors before they occur
  4. Debug efficiently - Use error context to locate root causes

Always check error codes and implement appropriate error handling in production applications.