koala73/worldmonitor · error · Error
${field} contains control characters
Error message
${field} contains control characters What it means
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.
Source
Thrown at shared/company-monitoring-contract.ts:82
const LOGICAL_ID_PREFIXES = {
company: 'cm_company_',
claim: 'cm_claim_',
event: 'cm_event_',
impact: 'cm_impact_',
evidence: 'cm_evidence_',
} as const;
const ULID = '[0-9A-HJKMNP-TV-Z]{26}';
const encoder = new TextEncoder();
function utf8Bytes(value: string): number {
return encoder.encode(value).byteLength;
}
function assertPlainText(value: unknown, field: string, maxBytes: number): string {
if (typeof value !== 'string') throw new Error(`${field} must be a string`);
const unicodeNormalized = value.normalize('NFC');
if (CONTROL_CHARACTERS.test(unicodeNormalized)) throw new Error(`${field} contains control characters`);
const normalized = unicodeNormalized.trim().replace(/\s+/g, ' ');
if (!normalized) throw new Error(`${field} is required`);
if (utf8Bytes(normalized) > maxBytes) throw new Error(`${field} exceeds ${maxBytes} bytes`);
return normalized;
}
function normalizeOptionalText(value: unknown, field: string, maxBytes: number): string | undefined {
if (value === undefined || value === null || value === '') return undefined;
return assertPlainText(value, field, maxBytes);
}
function normalizeList(
value: unknown,
field: string,
maxItems: number,
normalize: (item: unknown, index: number) => string,
): string[] {
if (value === undefined || value === null) return [];View on GitHub (pinned to eeab0a219f)
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
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at shared/company-monitoring-contract.ts:82 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21).
Data as JSON: /api/errors/10b4ddfb7beaa436.
Report an issue: GitHub.