{"record":{"id":"10b4ddfb7beaa436","repo":"koala73/worldmonitor","slug":"field-contains-control-characters","errorCode":null,"errorMessage":"${field} contains control characters","messagePattern":"(.+?) contains control characters","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"shared/company-monitoring-contract.ts","lineNumber":82,"sourceCode":"const LOGICAL_ID_PREFIXES = {\n  company: 'cm_company_',\n  claim: 'cm_claim_',\n  event: 'cm_event_',\n  impact: 'cm_impact_',\n  evidence: 'cm_evidence_',\n} as const;\nconst ULID = '[0-9A-HJKMNP-TV-Z]{26}';\n\nconst encoder = new TextEncoder();\n\nfunction utf8Bytes(value: string): number {\n  return encoder.encode(value).byteLength;\n}\n\nfunction assertPlainText(value: unknown, field: string, maxBytes: number): string {\n  if (typeof value !== 'string') throw new Error(`${field} must be a string`);\n  const unicodeNormalized = value.normalize('NFC');\n  if (CONTROL_CHARACTERS.test(unicodeNormalized)) throw new Error(`${field} contains control characters`);\n  const normalized = unicodeNormalized.trim().replace(/\\s+/g, ' ');\n  if (!normalized) throw new Error(`${field} is required`);\n  if (utf8Bytes(normalized) > maxBytes) throw new Error(`${field} exceeds ${maxBytes} bytes`);\n  return normalized;\n}\n\nfunction normalizeOptionalText(value: unknown, field: string, maxBytes: number): string | undefined {\n  if (value === undefined || value === null || value === '') return undefined;\n  return assertPlainText(value, field, maxBytes);\n}\n\nfunction normalizeList(\n  value: unknown,\n  field: string,\n  maxItems: number,\n  normalize: (item: unknown, index: number) => string,\n): string[] {\n  if (value === undefined || value === null) return [];","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/koala73/worldmonitor/blob/eeab0a219fce0f02a00603b532dbae9041b934ac/shared/company-monitoring-contract.ts#L64-L100","documentation":"Contract validation error from assertPlainText: after NFC Unicode normalization, the named string field contains control characters (per the CONTROL_CHARACTERS pattern). This is a sanitation guard against invisible/zero-width or C0/C1 control bytes in company-monitoring text inputs.","triggerScenarios":"Thrown at shared/company-monitoring-contract.ts:82 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Strip control characters from the field before submitting","Re-copy the text if it was pasted from a source with hidden formatting characters","Sanitize inputs client-side before sending the payload"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"eeab0a219fce0f02a00603b532dbae9041b934ac","analyzedAt":"2026-08-21T16:51:25.751Z","contentChangedAt":"2026-08-21T16:51:25.751Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}