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
{
  "ok": false,
  "error": {
    "code": "CONFIG_NOT_RESOLVED",
    "message": "No profile matched the current environment",
    "details": { "profileId": "production" }
  },
  "result": null,
  "meta": {}
}

Commands return one canonical envelope: { ok: true, result?, meta? } on success or { ok: false, error, result?, meta? } on failure. The result field carries plugin business data; meta carries optional execution metadata. A command's process exit code is an execution detail and is not part of the plugin result contract.

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

Command results, diagnostics, and retries

The command result envelope separates plugin business outcome from worker execution. A command may write useful diagnostics to stderr; those diagnostics are retained and streamed, but stderr alone does not make a command unsuccessful. A command is unsuccessful when it returns ok: false or the execution layer cannot complete it.

Workflow retries are policy-driven. A step is not retried merely because it produced stderr: retry requires an explicit failure and a retry policy that permits the failure classification. Network, timeout, rate-limit, and server failures are classified as transient when appropriate, while non-idempotent operations may still require an idempotency key before they can be retried.

Plugin and adapter authors should use the shared classifier from the SDK facade instead of defining local error-code or message-matching rules:

TypeScript
import { classifyFailure } from '@kb-labs/sdk';
 
const failure = classifyFailure(error, {
  source: 'command',
  phase: 'running',
});

The same taxonomy is used by CLI, execution, adapters, and workflow hosts.

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 plugins refresh # 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 plugins refresh

"Command not found" after building a plugin

Registry cache is stale:

Bash
pnpm kb marketplace plugins refresh

"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