{"record":{"id":"a3f03361bd06a793","repo":"Hmbown/CodeWhale","slug":"invalid-field","errorCode":null,"errorMessage":"Invalid ${field}.","messagePattern":"Invalid (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"pet/src/core/evidence.ts","lineNumber":61,"sourceCode":"  count: number; lastReceivedAt: number | null; sequenceGaps: number;\n}\nexport interface BoundaryFinding {\n  id: string; code: string; severity: 'info'|'warning'|'critical';\n  title: string; detail: string; recordIds: string[]; time: number;\n}\nexport interface Interaction {\n  runId: string; sandboxId?: string; group?: string; target: string;\n  kind: string; stage: Stage; effect: Effect; count: number; recordIds: string[];\n}\nexport interface BoundaryAnalysis {\n  version: 1; omittedFindings: number; asOf: number; inputRecords: number; visibleRecords: number; uniqueRecords: number;\n  futureRecords: number; findings: BoundaryFinding[]; coverage: CoverageRow[];\n  interactions: Interaction[]; runs: number; sandboxes: number; externalEffects: number;\n  unknownEffects: number; authority: { permitted: number; denied: number; unknown: number };\n  provenance: string;\n}\nconst enumValue = <T extends string>(v:unknown, values: readonly T[], field:string): T => {\n  if(typeof v!=='string'||!values.includes(v as T))throw new Error(`Invalid ${field}.`);return v as T;\n};\nconst object = (v:unknown, field:string): Record<string,unknown> => {\n  if(!v||typeof v!=='object'||Array.isArray(v))throw new Error(`Invalid ${field}: object required.`);return v as Record<string,unknown>;\n};\nconst text = (v:unknown, field:string, max=256):string => {\n  if(typeof v!=='string'||!v.length||v.length>max||/[\\u0000-\\u001f\\u007f]/.test(v))throw new Error(`Invalid ${field}: nonempty bounded text required.`);return v;\n};\nconst num = (v:unknown,field:string,min=0):number => {\n  if(typeof v!=='number'||!Number.isFinite(v)||v<min||Math.abs(v)>Number.MAX_SAFE_INTEGER)throw new Error(`Invalid ${field}.`);return v;\n};\nconst optionalText = (o:Record<string,unknown>,key:string):string|undefined => o[key]===undefined?undefined:text(o[key],key);\nconst strings = (v:unknown,field:string,allowEmpty=false):string[]=>{\n  if(!Array.isArray(v)||(!allowEmpty&&!v.length)||v.length>256)throw new Error(`Invalid ${field}.`);\n  const out=v.map(x=>text(x,field));if(new Set(out).size!==out.length)throw new Error(`Duplicate ${field}.`);return out;\n};\nconst boolean = (v:unknown,field:string):boolean=>{if(typeof v!=='boolean')throw new Error(`Invalid ${field}.`);return v;};\nconst optionalNumber=(o:Record<string,unknown>,key:string)=>o[key]===undefined?undefined:num(o[key],key);\nfunction onlyKeys(o:Record<string,unknown>,keys:string[],label:string):void{","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/433685b2024e7bc4c99e1e2e326bcad39b4d9d65/pet/src/core/evidence.ts#L43-L79","documentation":"enumValue is the evidence-module validator for string fields restricted to a fixed set of allowed values. It throws when a value is not a string or is not one of the allowed literals, with the field name interpolated into the message (e.g. 'Invalid kind.'). It guarantees enum-typed fields in observations, policies, and bundles are exactly one of the documented values.","triggerScenarios":"Calling validateObservation, validatePolicy, or the sources/g builders with a payload whose enum field (e.g. kind, effect class) is misspelled, has wrong casing, is a number/boolean, or is absent (undefined).","commonSituations":"Hand-writing evidence JSON with a typo like \"permitted\" vs \"allowed\"; a schema change between library versions renaming an enum member; serializing from another language where the enum became a number; forgetting to set the field at all.","solutions":["Check the error's field name and compare the value against the allowed literals for that field in the evidence schema.","Fix casing/spelling to match the documented enum member exactly (comparison is case-sensitive).","Ensure the field is present — undefined fails the string check too.","If your producer predates a schema rename, regenerate or migrate the evidence payload to the current schema."],"exampleFix":"// before\nvalidateObservation({ kind: 'syscall' })          // not an allowed value\n// after\nvalidateObservation({ kind: 'sandbox_escape' })   // one of the schema's enum members","handlingStrategy":"validation","validationCode":"const KINDS = ['sandbox_escape','syscall','net_connect','file_write']; // substitute the schema's literals\nfunction checkEnum(v, field, values) {\n  if (typeof v !== 'string' || !values.includes(v)) throw new Error(`${field} must be one of: ${values.join(', ')}`);\n}","typeGuard":"const isOneOf = (v, values) => typeof v === 'string' && values.includes(v);","tryCatchPattern":"try {\n  validateObservation(observation);\n} catch (e) {\n  if (e.message.startsWith('Invalid ') && !e.message.includes(':')) {\n    console.error(`enum field rejected: ${e.message}; check spelling/casing against the schema`);\n  } else throw e;\n}","preventionTips":["Copy enum literals from the schema/types rather than typing them from memory.","Use a const object or union type for enum values so typos become compile errors.","Validate enum fields at the producer boundary before serializing evidence.","When upgrading the library, diff enum members for renames and migrate payloads."],"tags":["validation","evidence","enum","schema"],"backgroundTag":"invalid-enum-value","analyzedSha":"433685b2024e7bc4c99e1e2e326bcad39b4d9d65","analyzedAt":"2026-09-15T12:24:24.634Z","contentChangedAt":"2026-09-15T12:24:24.634Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}