KB LabsDocs

Error Codes

Last updated April 7, 2026


Platform error codes, their meanings, and recovery actions.

KB Labs uses structured error codes throughout — in CLI output, REST API responses, and workflow logs. This page catalogs the known codes by subsystem.

Error shape

CLI output (JSON mode):

JSON
{
  "exitCode": 1,
  "error": {
    "code": "CONFIG_NOT_RESOLVED",
    "message": "No profile matched the current environment",
    "details": { "profileId": "production" }
  }
}

REST API:

JSON
{
  "error": {
    "code": "WORKFLOW_NOT_FOUND",
    "message": "Workflow run abc123 not found",
    "details": {}
  }
}

Thrown exceptions (caught by the runtime and mapped to one of the above):

TypeScript
throw new PluginError('INVALID_HANDLER', 'Handler at ./dist/run.js does not export execute');

Defining errors in plugins

Use defineError from @kb-labs/sdk to declare typed error codes in your plugin:

TypeScript
import { defineError } from '@kb-labs/sdk';
 
export const MyPluginErrors = {
  CONFIG_MISSING: defineError('CONFIG_MISSING', 400, 'Plugin configuration is missing'),
  LLM_UNAVAILABLE: defineError('LLM_UNAVAILABLE', 503, 'LLM adapter not configured'),
  PARSE_FAILED: defineError('PARSE_FAILED', 422, 'Failed to parse LLM response'),
};

commonErrors from @kb-labs/sdk provides pre-defined codes for the most frequent cases.

Platform error codes

Plugin loading

CodeHTTPMeaningFix
INVALID_MANIFEST400Manifest failed schema validationCheck schema, id, version fields are correct
INVALID_HANDLER400Handler file not found or missing execute exportVerify the handler path in the manifest points to built .js output
PLUGIN_NOT_FOUND404Plugin ID not in registryInstall the plugin or clear registry cache
PLUGIN_CONFLICT409Two plugins declare the same command IDRename one command's id
CIRCULAR_DEPENDENCY400Plugin dependency graph has a cycleCheck dependencies[] in manifests
MISSING_DEPENDENCY400Required plugin not installedInstall the dependency listed in plugin.dependencies

Configuration

CodeHTTPMeaningFix
CONFIG_NOT_FOUND404.kb/kb.config.json missingRun pnpm kb init or restore from backup
CONFIG_NOT_RESOLVED400No profile matched current environmentCheck profiles in kb.config.json
CONFIG_PARSE_ERROR400kb.config.json is invalid JSONFix JSON syntax
ADAPTER_NOT_CONFIGURED400Required adapter missing from configAdd adapter to kb.config.json

Execution

CodeHTTPMeaningFix
EXECUTION_TIMEOUT504Handler exceeded timeoutMsIncrease timeout in manifest or optimize handler
EXECUTION_ERROR500Handler threw an unhandled exceptionCheck logs: kb-dev logs rest
HOST_MISMATCH400Handler invoked from wrong host typeUse defineRoute for REST handlers, defineCommand for CLI
SANDBOX_ERROR500Plugin sandbox failed to initializeRun pnpm kb marketplace plugins doctor

Workflow

CodeHTTPMeaningFix
WORKFLOW_NOT_FOUND404Workflow ID not registeredCheck workflow handler declarations in manifests
WORKFLOW_RUN_NOT_FOUND404Run ID doesn't existVerify run ID
WORKFLOW_ALREADY_CANCELLED409Run was already cancelled
JOB_NOT_FOUND404Job handler ID not registeredCheck jobs.handlers[] in manifest
STEP_FAILED500A workflow step threwCheck run logs for step error

Rate limiting and quotas

CodeHTTPMeaningFix
RATE_LIMIT_EXCEEDED429Too many requests for tenantCheck Retry-After header; reduce request rate
QUOTA_EXCEEDED429Tenant exceeded daily/monthly quotaUpgrade tier or wait for quota reset
CONCURRENT_LIMIT_EXCEEDED429Too many concurrent workflow runsWait for running workflows to finish

Authentication and authorization

CodeHTTPMeaningFix
UNAUTHORIZED401Missing or invalid auth tokenProvide Authorization: Bearer <token> header
FORBIDDEN403Token valid but insufficient permissionsCheck plugin permissions and tenant tier
PERMISSION_DENIED403Plugin permission check failedCheck permissions in manifest; request needed grants

Exit codes (CLI)

Exit codeMeaning
0Success
1Command failed (expected error: bad input, missing config, etc.)
2CLI infrastructure error (plugin load failure, dispatch error)
130Interrupted by user (Ctrl+C)

The mapping from error codes to exit codes lives in mapCliErrorToExitCode in the CLI runtime. Plugins control exit codes by returning { exitCode: N } from their handlers.

Diagnosing errors

Get more context:

Bash
LOG_LEVEL=debug pnpm kb <command>     # verbose output
kb-dev logs rest                       # last 50 lines from REST API
kb-dev logs rest -f                    # follow in real time

Plugin loading issues:

Bash
pnpm kb marketplace plugins doctor     # diagnose all installed plugins
pnpm kb marketplace clear-cache --deep # clear all caches and retry

Workflow failures:

Bash
pnpm kb workflow:logs --run-id <id>    # full run log
# Or via REST:
GET http://localhost:5050/api/v1/workflows/runs/<id>
GET http://localhost:5050/api/v1/workflows/runs/<id>/logs

Common error patterns and fixes

"Plugin not found: @kb-labs/qa" / showing only test plugins

Zombie host-agent daemon processes are intercepting plugin execution:

Bash
pkill -9 -f "host-agent-app/dist/index.js"
pnpm kb marketplace clear-cache --deep

"Command not found" after building a plugin

Registry cache is stale:

Bash
pnpm kb marketplace clear-cache

"Cannot find module '@kb-labs/...'"

Dependencies not built in the right order:

Bash
npx kb-devkit-build-order --package=your-package
Error Codes — KB Labs Docs