{"record":{"id":"9fe98ad7fb927859","repo":"JuliusBrussee/caveman","slug":"mastrastudiolink-template-must-contain-the-trace","errorCode":null,"errorMessage":"mastraStudioLink: template must contain the {traceId} placeholder","messagePattern":"mastraStudioLink: template must contain the (.+?) placeholder","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/mastra/src/index.ts","lineNumber":786,"sourceCode":"\nexport interface MastraStudioLinkOptions {\n  /**\n   * REQUIRED. Mastra documents a Studio Observability tab but not a per-trace\n   * URL, so this package will not invent one. Supply the shape your Studio\n   * build uses, with `{traceId}` (and optionally `{baseUrl}`) placeholders —\n   * e.g. `\"{baseUrl}/observability?traceId={traceId}\"`.\n   */\n  template: string;\n  /** Defaults to {@link MASTRA_STUDIO_DEFAULT_BASE_URL}. */\n  baseUrl?: string;\n}\n\n/** Builds a Mastra Studio link from the caller-supplied template. */\nexport function mastraStudioLink(traceId: string, options: MastraStudioLinkOptions): string {\n  const id = requireNonEmpty(traceId, \"mastraStudioLink: traceId\");\n  const template = requireNonEmpty(options.template, \"mastraStudioLink: template\");\n  if (!template.includes(\"{traceId}\")) {\n    throw new Error(\"mastraStudioLink: template must contain the {traceId} placeholder\");\n  }\n  const baseUrl = trimTrailingSlashes(options.baseUrl ?? MASTRA_STUDIO_DEFAULT_BASE_URL);\n  return template.replaceAll(\"{baseUrl}\", baseUrl).replaceAll(\"{traceId}\", encodeURIComponent(id));\n}\n\n/**\n * The Caveman dashboard trace page: `{baseUrl}/traces/{traceId}?project_id=…`.\n *\n * The dashboard currently resolves the project from the workspace switcher and\n * ignores the query parameter; it is carried so the link is unambiguous about\n * which project's trace it means.\n */\nexport function cavemanTraceLink(baseUrl: string, projectId: string, traceId: string): string {\n  const base = requireBaseUrl(baseUrl, \"cavemanTraceLink: baseUrl\");\n  const project = requireNonEmpty(projectId, \"cavemanTraceLink: projectId\");\n  const trace = requireNonEmpty(traceId, \"cavemanTraceLink: traceId\");\n  return `${base}/traces/${encodeURIComponent(trace)}?project_id=${encodeURIComponent(project)}`;\n}","sourceCodeStart":768,"sourceCodeEnd":804,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/mastra/src/index.ts#L768-L804","documentation":"Error \"mastraStudioLink: template must contain the {traceId} placeholder\" thrown in JuliusBrussee/caveman.","triggerScenarios":"Thrown at packages/mastra/src/index.ts:786 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Include the {traceId} placeholder in the studio link template."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}