{"record":{"id":"f0f5c002322b8cc9","repo":"mastra-ai/mastra","slug":"observability-invalid-config","errorCode":"OBSERVABILITY_INVALID_CONFIG","errorMessage":"Invalid observability configuration: ${errorMessages}","messagePattern":"Invalid observability configuration: (.+?)","errorType":"validation","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"observability/mastra/src/default.ts","lineNumber":86,"sourceCode":"    super({\n      component: RegisteredLogger.OBSERVABILITY,\n      name: 'Observability',\n    });\n\n    if (config === undefined) {\n      config = {};\n    }\n\n    // Validate config with Zod\n    const validationResult = observabilityRegistryConfigSchema.safeParse(config);\n    if (!validationResult.success) {\n      const errorMessages = validationResult.error.issues\n        .map(\n          (err: { path: (string | number | symbol)[]; message: string }) =>\n            `${err.path.join('.') || 'config'}: ${err.message}`,\n        )\n        .join('; ');\n      throw new MastraError({\n        id: 'OBSERVABILITY_INVALID_CONFIG',\n        text: `Invalid observability configuration: ${errorMessages}`,\n        domain: ErrorDomain.MASTRA_OBSERVABILITY,\n        category: ErrorCategory.USER,\n        details: {\n          validationErrors: errorMessages,\n        },\n      });\n    }\n\n    // Validate individual configs if they are plain objects (not instances)\n    if (config.configs) {\n      for (const [name, configValue] of Object.entries(config.configs)) {\n        if (!isInstance(configValue)) {\n          const configValidation = observabilityConfigValueSchema.safeParse(configValue);\n          if (!configValidation.success) {\n            const errorMessages = configValidation.error.issues\n              .map(","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/observability/mastra/src/default.ts#L68-L104","documentation":"MastraError with id OBSERVABILITY_INVALID_CONFIG thrown from the observability DefaultObservability constructor when the top-level observability options fail Zod schema validation. The message embeds each Zod issue formatted as 'path: message' joined by semicolons, so it pinpoints exactly which option is wrong. It is categorized USER because it always reflects a caller-supplied configuration problem, not an internal fault.","triggerScenarios":"Calling `new DefaultObservability(config)` (directly or via Mastra's observability option) with an invalid top-level config: unknown option names, wrong option types (e.g. exporting: 'yes' instead of a boolean or object), or values outside allowed ranges — anything the schema rejects.","commonSituations":"Typos in option names like `exportor` instead of `exporters`; passing a string where an object is expected (exporting: 'true'); upgrading Mastra and using a removed/renamed option; copying a config snippet from a different Mastra version.","solutions":["Read the validationErrors detail (and the message) to find the exact path and message of the failing option, e.g. 'exporting: expected object, received string'.","Fix the named option to match the observability schema: booleans as booleans, exporter config as an object like { exporters: [...] }.","Compare against the current Mastra observability docs for your version and remove deprecated/renamed options.","Log or print the config object you pass and validate it with the same schema (or JSON.stringify it) before constructing to spot shape mismatches."],"exampleFix":"// before\nnew DefaultObservability({ exporting: 'true' });\n// after\nnew DefaultObservability({ exporting: true });","handlingStrategy":"validation","validationCode":"// validate config against the same schema before constructing\nimport { observabilityConfigSchema } from '@mastra/core/observability'; // or the package's exported schema\nconst result = observabilityConfigSchema.safeParse(myConfig);\nif (!result.success) {\n  console.error('Invalid observability config:', result.error.issues.map(i => `${i.path.join('.')}: ${i.message}`));\n}","typeGuard":"function isObservabilityError(e: unknown): e is { id: string; details?: { validationErrors?: string } } {\n  return typeof e === 'object' && e !== null && 'id' in e && (e as any).id === 'OBSERVABILITY_INVALID_CONFIG';\n}","tryCatchPattern":"try {\n  const obs = new DefaultObservability(config);\n} catch (err) {\n  if (err instanceof MastraError && err.id === 'OBSERVABILITY_INVALID_CONFIG') {\n    console.error('Observability config rejected:', err.details?.validationErrors);\n    throw new Error(`Fix observability config: ${err.message}`);\n  }\n  throw err;\n}","preventionTips":["Validate observability config with the schema in unit tests so bad configs fail CI, not runtime.","Type the config with the exported config type (satisfies Config) so option typos are compile errors.","After upgrading Mastra, diff your observability options against the current docs/changelog.","Keep config in typed code rather than untyped JSON parse results."],"tags":["configuration","schema-validation","observability","zod"],"backgroundTag":"schema-validation-failed","analyzedSha":"75dd419e613fe9c39f846ffc500716141b74fda6","analyzedAt":"2026-08-30T00:15:31.844Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}