{"record":{"id":"b63ca6f74c7c626c","repo":"mastra-ai/mastra","slug":"observability-invalid-instance-config","errorCode":"OBSERVABILITY_INVALID_INSTANCE_CONFIG","errorMessage":"Invalid configuration for observability instance '${name}': ${errorMessages}","messagePattern":"Invalid configuration for observability instance '(.+?)': (.+?)","errorType":"validation","errorClass":"MastraError","httpStatus":null,"severity":"error","filePath":"observability/mastra/src/default.ts","lineNumber":109,"sourceCode":"        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(\n                (err: { path: (string | number | symbol)[]; message: string }) =>\n                  `${err.path.join('.')}: ${err.message}`,\n              )\n              .join('; ');\n            throw new MastraError({\n              id: 'OBSERVABILITY_INVALID_INSTANCE_CONFIG',\n              text: `Invalid configuration for observability instance '${name}': ${errorMessages}`,\n              domain: ErrorDomain.MASTRA_OBSERVABILITY,\n              category: ErrorCategory.USER,\n              details: {\n                instanceName: name,\n                validationErrors: errorMessages,\n              },\n            });\n          }\n        }\n      }\n    }\n\n    // Resolve sensitive data filter setting (defaults to enabled).\n    const sensitiveDataFilterSetting = config.sensitiveDataFilter ?? true;\n    const shouldAutoApplySensitiveFilter = sensitiveDataFilterSetting !== false;\n    const sensitiveDataFilterOptions: SensitiveDataFilterOptions | undefined =","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/mastra-ai/mastra/blob/75dd419e613fe9c39f846ffc500716141b74fda6/observability/mastra/src/default.ts#L91-L127","documentation":"MastraError with id OBSERVABILITY_INVALID_INSTANCE_CONFIG thrown from the observability DefaultObservability constructor when one named instance under `instances` fails Zod schema validation. Unlike OBSERVABILITY_INVALID_CONFIG (top-level), this error names the failing instance in the message and details.instanceName, with per-issue 'path: message' strings. It is a USER-category error reflecting a malformed per-instance configuration object.","triggerScenarios":"Passing an `instances` record to DefaultObservability where at least one entry (e.g. `instances: { prod: { ... } }`) has invalid fields — bad option names, wrong types, or invalid values — detected during the constructor's per-instance configValidation.","commonSituations":"Mixing top-level-only options into an instance config; a typo in one instance while others are valid; renaming or restructuring instances after a Mastra version upgrade; templating errors that render one instance's config as a string or drop a required field.","solutions":["Use the instanceName detail and the message's per-path messages to identify which named instance and which field is invalid.","Correct that instance's config to satisfy the observability instance schema (same option rules as the top-level config).","Validate the whole instances object against the schema or run it through the same Zod parser in a test to catch all bad instances at once.","Check the docs/changelog for your Mastra version to ensure instance-level options have not changed shape."],"exampleFix":"// before\nnew DefaultObservability({ instances: { prod: { exporters: 'traces' } } });\n// after\nnew DefaultObservability({ instances: { prod: { exporters: [{ type: 'traces', /* ... */ }] } } });","handlingStrategy":"validation","validationCode":"// validate each named instance before constructing\nfor (const [name, inst] of Object.entries(instances ?? {})) {\n  const res = observabilityInstanceConfigSchema.safeParse(inst);\n  if (!res.success) {\n    console.error(`Instance '${name}' invalid:`, res.error.issues.map(i => `${i.path.join('.')}: ${i.message}`));\n  }\n}","typeGuard":"function isInvalidInstanceConfigError(e: unknown): e is MastraError & { details: { instanceName: string; validationErrors?: string } } {\n  return e instanceof MastraError && e.id === 'OBSERVABILITY_INVALID_INSTANCE_CONFIG';\n}","tryCatchPattern":"try {\n  const obs = new DefaultObservability({ instances });\n} catch (err) {\n  if (err instanceof MastraError && err.id === 'OBSERVABILITY_INVALID_INSTANCE_CONFIG') {\n    const bad = (err.details as { instanceName?: string }).instanceName;\n    console.error(`Fix observability instance '${bad}':`, err.details?.validationErrors);\n    throw err;\n  }\n  throw err;\n}","preventionTips":["Type each instance with the exported instance config type so shape errors surface at compile time.","Validate all instances in a unit test with the instance schema; fail CI listing every bad instance.","When adding a new instance, copy a known-valid instance's shape rather than free-typing options.","After Mastra upgrades, re-run instance config validation tests before deploy."],"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"}