KrakenHashes Error Codes Reference¶
This document provides a comprehensive reference for all error codes, HTTP status codes, and error conditions used throughout the KrakenHashes system.
Table of Contents¶
- HTTP Status Codes
- Application Error Types
- Agent Error Conditions
- WebSocket Error Messages
- Common Error Scenarios
HTTP Status Codes¶
The KrakenHashes API uses standard HTTP status codes to indicate the success or failure of requests.
Success Codes (2xx)¶
| Code | Name | Usage |
|---|---|---|
| 200 | OK | Standard successful response for GET, PUT, DELETE requests |
| 201 | Created | Resource successfully created (POST requests) |
| 204 | No Content | Successful request with no response body (DELETE requests) |
Client Error Codes (4xx)¶
| Code | Name | Common Usage |
|---|---|---|
| 400 | Bad Request | Invalid request format, missing required fields, validation errors |
| 401 | Unauthorized | Missing or invalid authentication credentials |
| 403 | Forbidden | Valid credentials but insufficient permissions |
| 404 | Not Found | Requested resource does not exist |
| 409 | Conflict | Conflict with current state (e.g., duplicate records) |
Server Error Codes (5xx)¶
| Code | Name | Usage |
|---|---|---|
| 500 | Internal Server Error | Unexpected server error, database errors, system failures |
| 502 | Bad Gateway | WebSocket upgrade failures, proxy errors |
| 503 | Service Unavailable | Server temporarily unavailable (maintenance, overload) |
Application Error Types¶
Model Layer Errors (backend/internal/models/errors.go)¶
Repository Layer Errors (backend/internal/repository/errors.go)¶
var (
// Resource Errors
ErrNotFound = errors.New("resource not found")
ErrDuplicateRecord = errors.New("duplicate record")
// Validation Errors
ErrInvalidStatus = errors.New("invalid status")
ErrInvalidToken = errors.New("invalid token")
ErrInvalidHardware = errors.New("invalid hardware information")
ErrInvalidMetrics = errors.New("invalid metrics")
// Voucher Errors
ErrInvalidVoucher = errors.New("invalid or expired voucher")
ErrVoucherAlreadyUsed = errors.New("voucher has already been used")
ErrVoucherDeactivated = errors.New("voucher has been deactivated")
ErrVoucherExpired = errors.New("voucher has expired")
// Agent Errors
ErrDuplicateToken = errors.New("agent token already exists")
ErrAgentNotFound = errors.New("agent not found")
)
Agent Error Conditions¶
Registration Errors¶
| Error | HTTP Status | Description |
|---|---|---|
| Invalid claim code | 400 | The provided claim code is invalid or has been used |
| Expired claim code | 400 | The claim code has expired |
| Registration failed | 500 | Server error during agent registration |
Authentication Errors¶
| Error | HTTP Status | Description |
|---|---|---|
| Missing API key | 401 | API key header not provided |
| Invalid API key | 401 | API key does not match any registered agent |
| Agent ID mismatch | 401 | API key does not match the provided agent ID |
| TLS required | 400 | WebSocket connection requires TLS |
Connection Errors¶
| Error | Description |
|---|---|
| WebSocket upgrade failed | Failed to upgrade HTTP connection to WebSocket |
| Connection timeout | Agent failed to send heartbeat within timeout period |
| Invalid message format | WebSocket message does not match expected JSON format |
WebSocket Error Messages¶
Message Types¶
The WebSocket protocol uses typed messages for communication between agents and the server.
Server to Agent Error Messages¶
{
"type": "error_report",
"payload": {
"error": "error_message",
"code": "ERROR_CODE",
"details": {}
}
}
Agent to Server Error Messages¶
{
"type": "error_report",
"payload": {
"agent_id": 123,
"error": "error description",
"stack": "stack trace if available",
"context": {},
"reported_at": "2025-01-20T10:30:00Z"
}
}
WebSocket Message Types¶
Agent → Server Messages¶
| Type | Purpose |
|---|---|
heartbeat | Regular heartbeat to maintain connection |
task_status | Task execution status updates |
job_progress | Job progress updates |
benchmark_result | GPU benchmark results |
agent_status | Agent status changes |
error_report | Error reporting |
hardware_info | Hardware capability updates |
file_sync_response | File synchronization responses |
file_sync_status | File sync progress updates |
hashcat_output | Hashcat execution output |
device_detection | GPU device detection results |
device_update | GPU device status updates |
Server → Agent Messages¶
| Type | Purpose |
|---|---|
task_assignment | New task assignment |
job_stop | Stop job execution |
benchmark_request | Request GPU benchmark |
agent_command | Generic agent command |
config_update | Configuration updates |
file_sync_request | Request file inventory |
file_sync_command | File download commands |
force_cleanup | Force cleanup of resources |
Common Error Scenarios¶
Authentication Flow Errors¶
- Login Failures
- Invalid credentials → 401 Unauthorized
- System user login attempt → 401 Unauthorized
-
MFA required but not provided → Response with MFA session
-
Token Errors
- Expired access token → 401 Unauthorized
- Invalid refresh token → 401 Unauthorized
-
Expired refresh token → 401 Unauthorized
-
MFA Errors
- Invalid TOTP code → 400 Bad Request
- Invalid email code → 400 Bad Request
- Expired MFA session → 401 Unauthorized
- Invalid backup code → 400 Bad Request
File Operation Errors¶
- Upload Errors
- File too large → 400 Bad Request
- Invalid file type → 400 Bad Request
-
Disk space exceeded → 507 Insufficient Storage
-
Download Errors
- File not found → 404 Not Found
- Access denied → 403 Forbidden
Job Execution Errors¶
- Job Creation
- Invalid job parameters → 400 Bad Request
- Missing required fields → 400 Bad Request
-
Invalid hashlist ID → 404 Not Found
-
Job Execution
- No available agents → 503 Service Unavailable
- Agent disconnected → Task is truncated-and-completed, deleted, or cancelled, and its keyspace range is re-dispatched. The job is not failed. See Task Lifecycle and Statuses
- Hashcat execution error → Agent-reported task failure (
failed), which fails the whole job
Cloud Provisioning Errors¶
Cloud errors divide into two classes, and the distinction decides whether money is at stake. A definitive failure means no instance exists; an ambiguous one means an instance may be running and billing right now.
- Configuration — refused before anything is spent
- No VPN provider configured → refused. "the backend is not internet-exposed, so an instance that cannot join your VPN would bill until its watchdog fired"
- Unsupported VPN provider → refused, naming OpenVPN's
/dev/net/tun/CAP_NET_ADMINrequirement - Missing credentials, VPN credential, or
backend_vpn_host→ provider cannot be enabled - Expired reusable VPN key → "the reusable
<provider>key expired at<time>; rotate it before provisioning" -
Peer provider without acknowledgement → refused at provider level and again per client
-
Provisioning refusals — no spend, diagnostic recorded on the job
cloud_rental_too_short— the rental would be mostly commissioning. Two distinct messages depending on whether the client's TTL ceiling or their remaining budget is binding, because telling someone to top up a budget when their own ceiling is the problem sends them to the wrong screen- Budget reached, instance cap reached, outside the provisioning window, below the minimum job priority → skip reasons shown on the job detail page
-
Unfunded client → cannot provision at all, distinct from being at 100% of budget
-
Launch outcomes
ErrOfferUnavailable— definitive. The provider refused for capacity (InsufficientInstanceCapacity). The budget reservation is released and the claim voucher deactivated, and the retry loop moves to the next candidateVcpuLimitExceeded/MaxSpotInstanceCountExceeded— account quotas that will never clear without a limit-increase request, unlike a capacity refusalUnauthorizedOperation(bare, no detail) → aRunInstancesARN type is missing from the IAM policy. See AWS IAM-
Anything else — ambiguous. The instance row is left for the reaper to reconcile by label, the reservation is not released, and the claim voucher is deliberately left active because the instance may be running and its agent still has to register
-
Teardown
DELETE /instances/{id}returning 502 → the provider refused the destroy. The instance is still billing. It keeps accruing and keeps blocking new provisioning for its client until resolved- Repeated teardown failure → admins are paged with the raw provider ID; the instance is never reported terminated, because that would hide real spend
-
AGENT_DISK_FULLon a cloud agent → treated as structural, not transient. The instance is terminated rather than retried into a loop that burns its whole TTL, because container-provider disk cannot grow after creation -
Capacity explorer (
GET /providers/{id}/capacity) - 502 — the provider was reachable but the probe failed. Unlike pre-flight, this is a real error: without the placement list there is no screen to render
- 501 — the provider chooses placement itself and has no axis to select. Today only
mock
Inconclusive is failure, not success
Pre-flight returns 200 even when it fails — a failing pre-flight is a successful diagnosis, and the report body is the actionable part. But ok is false whenever any check is inconclusive: an unknown is not permission to spend money. On AWS that makes pre-flight stricter than launching, since a denied servicequotas:* or ec2:DescribeInstances lands there while a launch would still work.
Database Errors¶
- Connection Errors
- Database unreachable → 500 Internal Server Error
-
Connection pool exhausted → 500 Internal Server Error
-
Query Errors
- Record not found → 404 Not Found
- Duplicate key violation → 409 Conflict
- Foreign key constraint → 400 Bad Request
Error Resolution Guide¶
For API Consumers¶
- 401 Unauthorized
- Check if access token is expired
- Refresh token if needed
-
Ensure proper authentication headers
-
403 Forbidden
- Verify user has required permissions
-
Check role-based access requirements
-
404 Not Found
- Verify resource ID is correct
-
Check if resource was deleted
-
500 Internal Server Error
- Retry with exponential backoff
- Check server logs for details
- Contact support if persistent
For Agent Developers¶
- WebSocket Connection Issues
- Ensure TLS is enabled
- Verify API key is valid
-
Check network connectivity
-
File Sync Errors
- Verify file permissions
- Check disk space
-
Ensure file hashes match
-
Job Execution Errors
- Check hashcat installation
- Verify GPU drivers
- Monitor system resources
Error Logging¶
All errors are logged with appropriate severity levels:
- DEBUG: Detailed debugging information
- INFO: General informational messages
- WARNING: Warning messages for potential issues
- ERROR: Error messages for failures
- CRITICAL: Critical system failures
Error logs include: - Timestamp - Error message - Stack trace (when available) - Request context - User/Agent information
Best Practices¶
- Client-Side Error Handling
- Always check HTTP status codes
- Parse error response bodies
- Implement retry logic for transient errors
-
Display user-friendly error messages
-
Server-Side Error Handling
- Use consistent error formats
- Include helpful error details
- Log errors with appropriate context
-
Monitor error rates and patterns
-
Agent Error Handling
- Report errors via WebSocket
- Implement local error recovery
- Maintain error history
- Include system state in error reports