{"record":{"id":"e0ba4c4308601c4f","repo":"mastra-ai/mastra","slug":"experiment-target-not-found","errorCode":"EXPERIMENT_TARGET_NOT_FOUND","errorMessage":"Target not found: ${args!.targetType} \"${args!.targetId}\"","messagePattern":"Target not found: (.+?) \"(.+?)\"","errorType":"error_code","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"packages/core/src/datasets/dataset.ts","lineNumber":676,"sourceCode":"        text: `targetType and targetId must be provided together (got targetType: ${args?.targetType ?? 'none'}, targetId: ${args?.targetId ?? 'none'})`,\n        domain: 'STORAGE',\n        category: 'USER',\n      });\n    }\n    if (args?.scorers?.length && !hasTargetType) {\n      throw new MastraError({\n        id: 'EXPERIMENT_INVALID_TARGET',\n        text: 'scorers require a target: without a target Mastra never executes or scores items; submit flat scores via submitExperimentResult instead',\n        domain: 'STORAGE',\n        category: 'USER',\n      });\n    }\n    // Validate the target exists in this Mastra registry at create time so a\n    // typo fails fast instead of failing on the first runExperimentItem call.\n    if (hasTargetType) {\n      const resolved = await resolveTarget(this.#mastra, args!.targetType!, args!.targetId!);\n      if (!resolved) {\n        throw new MastraError({\n          id: 'EXPERIMENT_TARGET_NOT_FOUND',\n          text: `Target not found: ${args!.targetType} \"${args!.targetId}\"`,\n          domain: 'STORAGE',\n          category: 'USER',\n        });\n      }\n    }\n\n    const dataset = await datasetsStore.getDatasetById({ id: this.id, filters: this.#scope });\n    if (!dataset) {\n      throw new MastraError({\n        id: 'DATASET_NOT_FOUND',\n        text: `Dataset not found: ${this.id}`,\n        domain: 'STORAGE',\n        category: 'USER',\n      });\n    }\n","sourceCodeStart":658,"sourceCodeEnd":694,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/packages/core/src/datasets/dataset.ts#L658-L694","documentation":"createExperiment resolves the target (agent, workflow, etc.) in the local Mastra registry at creation time so typos fail immediately. If resolveTarget finds nothing for the given targetType/targetId, this error is thrown.","triggerScenarios":"Calling createExperiment with a targetId that doesn't exist in this Mastra instance, or a targetType with no registered entity of that id.","commonSituations":"Typo in agent/workflow name; target registered on a different Mastra instance than the Dataset handle uses; renaming an agent without updating experiments; target registered after createExperiment is called.","solutions":["Register the target (mastra.registerAgent / add workflow) before creating the experiment","Fix the targetId spelling to match the registry","Ensure createExperiment is called on the same Mastra instance where the target lives"],"exampleFix":"// before\nawait dataset.createExperiment({ targetType: 'agent', targetId: 'summarizer' }); // not registered\n// after\nmastra.registerAgent({ name: 'summarizer', ... });\nawait dataset.createExperiment({ targetType: 'agent', targetId: 'summarizer' });","handlingStrategy":"validation","validationCode":"const resolved = await resolveTarget(mastra, args.targetType, args.targetId);\nif (!resolved) throw new Error(`Target ${args.targetType} \"${args.targetId}\" is not registered in this Mastra instance`);","typeGuard":"function isRegisteredTarget(t: { targetType: string; targetId: string }, mastra: Mastra): boolean { return resolveTarget(mastra, t.targetType, t.targetId) != null; }","tryCatchPattern":"try {\n  await dataset.createExperiment(args);\n} catch (e) {\n  if (isMastraError(e) && e.id === 'EXPERIMENT_TARGET_NOT_FOUND') {\n    console.error(`Register ${args.targetType} \"${args.targetId}\" before creating the experiment`);\n  } else throw e;\n}","preventionTips":["Register all agents/workflows during app bootstrap before experiments","Keep target ids in a shared constants module to avoid typos","Validate experiment configs against the registry in CI"],"tags":["storage","experiment","not-found","registry"],"backgroundTag":"resource-not-found","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}