{"record":{"id":"d859477a63b81894","repo":"n8n-io/n8n","slug":"no-artifact-handler-registered-for-type-type","errorCode":null,"errorMessage":"no artifact handler registered for type: ${type}","messagePattern":"no artifact handler registered for type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@n8n/instance-ai/evaluations/harness/artifacts/registry.ts","lineNumber":17,"sourceCode":"import { agentHandler } from './agent-handler';\nimport { configEvalHandler } from './config-eval-handler';\nimport type { ArtifactHandler } from './types';\nimport { workflowHandler } from './workflow-handler';\nimport type { ArtifactType } from '../../types';\n\n/** All registered artifact handlers. */\nexport const ARTIFACT_HANDLERS: ArtifactHandler[] = [\n\tworkflowHandler,\n\tagentHandler,\n\tconfigEvalHandler,\n];\n\n/** Look up a handler by artifact type. Throws for an unregistered type. */\nexport function getHandler(type: ArtifactType): ArtifactHandler {\n\tconst handler = ARTIFACT_HANDLERS.find((h) => h.type === type);\n\tif (!handler) throw new Error(`no artifact handler registered for type: ${type}`);\n\treturn handler;\n}\n","sourceCodeStart":1,"sourceCodeEnd":20,"githubUrl":"https://github.com/n8n-io/n8n/blob/5ac6606e81f67bb9534255570cd4e86fd8101eee/packages/@n8n/instance-ai/evaluations/harness/artifacts/registry.ts#L1-L20","documentation":"Thrown by getHandler() in the artifact registry when no handler in ARTIFACT_HANDLERS matches the requested ArtifactType. The registry is a fixed array (workflow, agent, config-eval). ArtifactType is itself a closed union ('workflow' | 'agent' | 'config-eval'), so at the type level this throw is unreachable for well-typed callers; it fires when a value reaches the registry outside that union (e.g. an unvalidated JSON field, an `as` cast, or a new type added to ARTIFACT_TYPES without a handler).","triggerScenarios":"A new artifact kind is added to ARTIFACT_TYPES but no handler is appended to ARTIFACT_HANDLERS; a test-case expectation array carries a type string from unvalidated input; an `as ArtifactType` cast on a value the schema didn't actually narrow.","commonSituations":"Extending the eval framework with a new artifact type (e.g. 'credential') and forgetting the handler; loading a test case from JSON without running it through the Zod schema that constrains the type.","solutions":["If you added a type to ARTIFACT_TYPES, implement an ArtifactHandler and append it to ARTIFACT_HANDLERS in registry.ts.","If the value came from JSON, route it through the Zod schema so an invalid type fails at parse, not at handler lookup.","Remove any `as ArtifactType` casts and rely on schema narrowing."],"exampleFix":"// before\nexport const ARTIFACT_HANDLERS: ArtifactHandler[] = [workflowHandler, agentHandler, configEvalHandler];\n// new type 'credential' added to ARTIFACT_TYPES but no handler\n// after\nimport { credentialHandler } from './credential-handler';\nexport const ARTIFACT_HANDLERS: ArtifactHandler[] = [\n  workflowHandler,\n  agentHandler,\n  configEvalHandler,\n  credentialHandler,\n];","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"// Narrow an artifact type to the registered set before handler lookup.\nimport { ARTIFACT_TYPES } from '../../types';\nconst REGISTERED = new Set<string>(ARTIFACT_TYPES);\nfunction isRegisteredArtifactType(type: string): type is 'workflow' | 'agent' | 'config-eval' {\n  return REGISTERED.has(type);\n}\n// Usage:\nif (!isRegisteredArtifactType(type)) {\n  throw new Error(`Unknown artifact type \"${type}\". Registered: ${[...REGISTERED].join(', ')}`);\n}\nconst handler = getHandler(type);","tryCatchPattern":null,"preventionTips":["Never append a type to ARTIFACT_TYPES without appending a handler to ARTIFACT_HANDLERS — add a test that asserts 1:1 coverage.","Run all artifact-bearing JSON through the Zod schema so invalid types fail at parse, not at registry lookup.","Avoid `as ArtifactType` casts; rely on schema narrowing."],"tags":["registry","artifact","type-system","exhaustiveness"],"backgroundTag":null,"analyzedSha":"5ac6606e81f67bb9534255570cd4e86fd8101eee","analyzedAt":"2026-08-12T05:26:35.080Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}