{"id":"f4970627f1dac54a","repo":"prisma/prisma","slug":"psl-extension-invalid-value-f49706","errorCode":"PSL_EXTENSION_INVALID_VALUE","errorMessage":"enum \"${block.name}\" @@type references unknown codec \"${codecId}\"","messagePattern":"enum \"(.+?)\" @@type references unknown codec \"(.+?)\"","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/2-sql/9-family/src/core/authoring-entity-types.ts","lineNumber":33,"sourceCode":"  discriminator: 'enum',\n  output: {\n    factory: (\n      block: PslExtensionBlock,\n      ctx: AuthoringEntityContext,\n    ): EnumTypeHandle | undefined => {\n      const sourceId = ctx.sourceId ?? 'unknown';\n      const diagnostics = ctx.diagnostics;\n\n      const resolved = resolveEnumCodecId(block, ctx);\n      if (resolved === undefined) {\n        return undefined;\n      }\n      const { codecId, codecSpan } = resolved;\n\n      const nativeType = ctx.codecLookup?.targetTypesFor(codecId)?.[0];\n      if (nativeType === undefined) {\n        diagnostics?.push({\n          code: 'PSL_EXTENSION_INVALID_VALUE',\n          message: `enum \"${block.name}\" @@type references unknown codec \"${codecId}\"`,\n          sourceId,\n          span: codecSpan,\n        });\n        return undefined;\n      }\n\n      const codec = ctx.codecLookup?.get(codecId);\n      if (codec === undefined) {\n        diagnostics?.push({\n          code: 'PSL_EXTENSION_INVALID_VALUE',\n          message: `enum \"${block.name}\" @@type codec \"${codecId}\" resolves in targetTypesFor but is absent from codecLookup.get`,\n          sourceId,\n          span: codecSpan,\n        });\n        return undefined;\n      }\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/prisma/prisma/blob/1243cdffbec0506c595ac8fd5865fe258c336fa0/packages/2-sql/9-family/src/core/authoring-entity-types.ts#L15-L51","documentation":"Emitted by the SQL family's enum entity factory when an `enum` block's `@@type` references a codec id whose native type is unknown to the target — `codecLookup.targetTypesFor(codecId)` returns `undefined`/empty. The codec is either not registered for this target or is misspelled, so the library cannot determine the column's native storage type and aborts enum construction (returns `undefined`).","triggerScenarios":"Authoring `enum Status { ACTIVE INACTIVE } @@type \"custom_codec\"` where `custom_codec` is not registered in the target's codec registry. Triggered in `sqlFamilyEnumEntityDescriptor.output.factory` when `ctx.codecLookup?.targetTypesFor(codecId)?.[0]` is `undefined`.","commonSituations":"Typo in the `@@type` codec id. Using a codec from a target extension that is not composed for the current target. Upgrading the family/target and forgetting to register a custom codec. Authoring an enum before its codec exists.","solutions":["Verify the codec id spelled in `@@type \"...\"` exactly matches a registered codec for the current target.","Register the missing codec via the target/family's codec contribution (`AuthoringContributions` / codec registry) before authoring the enum.","Ensure the target extension providing the codec is composed (see uncomposed-namespace guidance) for this family+target.","If the codec was renamed in a version bump, update the `@@type` reference to the new id."],"exampleFix":"// before\nenum Status {\n  ACTIVE\n  INACTIVE\n} @@type \"statuz\"   // typo / unregistered\n\n// after\nenum Status {\n  ACTIVE\n  INACTIVE\n} @@type \"status\"","handlingStrategy":"validation","validationCode":"// Validate the codec referenced by an enum's @@type exists before authoring the enum block.\nfunction codecIsKnown(codecLookup: { targetTypesFor: (id: string) => unknown[] } | undefined, codecId: string): boolean {\n  return (codecLookup?.targetTypesFor(codecId)?.length ?? 0) > 0;\n}\n\nif (!codecIsKnown(codecLookup, codecId)) {\n  throw new Error(`Enum @@type references unknown codec \"${codecId}\". Register the codec with the target before authoring the enum.`);\n}\n\n// Also scan post-authoring diagnostics:\nconst unknownCodec = diagnostics.filter(\n  (d) => d.code === 'PSL_EXTENSION_INVALID_VALUE' && d.message.includes('unknown codec'),\n);\nif (unknownCodec.length > 0) throw new Error(unknownCodec.map((d) => d.message).join('\\n'));","typeGuard":"function isUnknownCodecDiagnostic(d: unknown): d is ContractSourceDiagnostic & { code: 'PSL_EXTENSION_INVALID_VALUE' } {\n  return typeof d === 'object' && d !== null && (d as ContractSourceDiagnostic).code === 'PSL_EXTENSION_INVALID_VALUE' && /unknown codec/.test((d as ContractSourceDiagnostic).message);\n}","tryCatchPattern":"// Collected diagnostic, not thrown. Validate diagnostics after enum authoring; try/catch only around emit.\ntry {\n  emitContract(resolvedContract);\n} catch (err) {\n  if (unknownCodec.length > 0) throw new Error('Emit blocked: enum references unknown codec');\n  throw err;\n}","preventionTips":["Register the target codec (via the storage type extension) for the family/target BEFORE authoring an enum that references it with @@type.","Reference codec ids that you obtained from the codec registry rather than hand-typing ids, to avoid typos that resolve to 'unknown codec'.","Add a CI check that fails on any 'PSL_EXTENSION_INVALID_VALUE' diagnostic containing 'unknown codec'."],"tags":["psl","enum","codec","extension","family"],"analyzedSha":"1243cdffbec0506c595ac8fd5865fe258c336fa0","analyzedAt":"2026-08-01T19:42:02.087Z","schemaVersion":2}