koala73/worldmonitor · error · Error

${field} is required

Error message

${field} is required

What it means

Contract validation error from assertPlainText: the named field is empty after NFC normalization, whitespace collapsing, and trimming. It is a required-field guard — the caller sent an all-whitespace or empty string where a non-empty value is mandatory.

Source

Thrown at shared/company-monitoring-contract.ts:84

  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 [];
  if (!Array.isArray(value)) throw new Error(`${field} must be a list`);
  if (value.length > maxItems) throw new Error(`${field} exceeds ${maxItems} items`);

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Provide actual non-whitespace content for the field
  2. Fix client UI that allows submitting blank values
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at shared/company-monitoring-contract.ts:84 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/23a41a3048279bfd. Report an issue: GitHub.