{"record":{"id":"474fe9a6e840baf9","repo":"mastra-ai/mastra","slug":"unknown-target-type-targettype","errorCode":null,"errorMessage":"Unknown target type: ${targetType}","messagePattern":"Unknown target type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/datasets/experiment/executor.ts","lineNumber":167,"sourceCode":"          signal,\n          options?.requestContext,\n          options?.experimentId,\n          options?.versions,\n          options?.toolMocks,\n          options?.unmockedToolPolicy,\n        );\n        break;\n      case 'workflow':\n        executionPromise = executeWorkflow(target as Workflow, item, options?.requestContext);\n        break;\n      case 'scorer':\n        executionPromise = executeScorer(target as MastraScorer<any, any, any, any>, item);\n        break;\n      case 'processor':\n        // Processor targets dropped from roadmap - not a core use case\n        throw new Error(`Target type '${targetType}' not yet supported.`);\n      default:\n        throw new Error(`Unknown target type: ${targetType}`);\n    }\n\n    // Race execution against signal abort (ensures timeout works even if target ignores signal)\n    if (signal) {\n      return await raceWithSignal(executionPromise, signal);\n    }\n\n    return await executionPromise;\n  } catch (error) {\n    return {\n      output: null,\n      error: {\n        message: error instanceof Error ? error.message : String(error),\n        stack: error instanceof Error ? error.stack : undefined,\n      },\n      traceId: null,\n    };\n  }","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/experiment/executor.ts#L149-L185","documentation":"executeTarget's switch statement hits its default branch when the experiment target type is not one of the recognized kinds (agent/tool/workflow/scorer; processor is separately rejected). This indicates an invalid or unrecognized targetType value reached the executor.","triggerScenarios":"Passing a misspelled or arbitrary targetType (e.g. 'Agent', 'llm', 'model') to runExperiment, or loading a persisted experiment config whose targetType no longer matches the executor's accepted set.","commonSituations":"Typo or wrong casing in config files; dynamic targetType built from user input; schema drift after upgrading @mastra/core where allowed target types changed.","solutions":["Set targetType to one of 'agent' | 'tool' | 'workflow' | 'scorer'","Validate/normalize the targetType string (lowercase, trim) before calling runExperiment","If loaded from storage, migrate the persisted experiment config to a supported target type"],"exampleFix":"// before\nrunExperiment({ targetType: 'Agent', targetId: 'my-agent' });\n// after\nconst targetType = 'agent' as const;\nrunExperiment({ targetType, targetId: 'my-agent' });","handlingStrategy":"validation","validationCode":"const SUPPORTED = ['agent', 'tool', 'workflow', 'scorer'] as const;\nif (!SUPPORTED.includes(targetType)) {\n  throw new Error(`Invalid targetType: ${targetType}`);\n}","typeGuard":"type SupportedTargetType = 'agent' | 'tool' | 'workflow' | 'scorer';\nfunction isSupportedTargetType(t: unknown): t is SupportedTargetType {\n  return typeof t === 'string' && ['agent', 'tool', 'workflow', 'scorer'].includes(t);\n}","tryCatchPattern":"try {\n  await runExperiment(config);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Unknown target type')) {\n    console.error(`Bad targetType in experiment config: ${err.message}`);\n  } else throw err;\n}","preventionTips":["Use a union type / zod schema for targetType in config files","Normalize casing before passing targetType","Avoid building targetType from free-form user input","Validate persisted experiment configs after upgrades"],"tags":["configuration","experiment","invalid-argument","user-input"],"backgroundTag":"unsupported-target-type","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}