koala73/worldmonitor · error · ValidationError

forms must be a comma-separated form list such as "8-K" or "

Error message

forms must be a comma-separated form list such as "8-K" or "10-K,10-Q"

What it means

searchSecFilings reports this violation (field 'forms') when normalizeEdgarForms returns null, i.e. req.forms cannot be interpreted as a comma-separated EDGAR form list like "8-K" or "10-K,10-Q". It is aggregated with any date violations into one ValidationError thrown together, and — like the other filters — fails closed so a dropped filter cannot silently widen the result set.

Source

Thrown at server/worldmonitor/intelligence/v1/search-sec-filings.ts:49

  const startDateValid = !req.startDate || isEdgarIsoDate(req.startDate);
  const endDateValid = !req.endDate || isEdgarIsoDate(req.endDate);
  const violations = [
    ...(formsNormalized === null
      ? [{ field: 'forms', description: 'forms must be a comma-separated form list such as "8-K" or "10-K,10-Q"' }]
      : []),
    ...(!startDateValid
      ? [{ field: 'start_date', description: 'start_date must be YYYY-MM-DD' }]
      : []),
    ...(!endDateValid
      ? [{ field: 'end_date', description: 'end_date must be YYYY-MM-DD' }]
      : []),
    ...(req.startDate && req.endDate
      && startDateValid && endDateValid
      && req.startDate > req.endDate
      ? [{ field: 'start_date', description: 'start_date must not be after end_date' }]
      : []),
  ];
  if (violations.length > 0) throw new ValidationError(violations);

  const limit = req.limit > 0 ? Math.min(req.limit, MAX_LIMIT) : DEFAULT_LIMIT;

  const result = await searchEdgarFullText({
    query,
    forms: formsNormalized || undefined,
    startDate: req.startDate,
    endDate: req.endDate,
    size: limit,
  });

  if (!result) {
    return { results: [], total: 0, unavailable: true, fetchedAtMs: Date.now() };
  }

  return {
    results: result.results.slice(0, limit),
    total: result.total,

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Send forms as a comma-separated list of EDGAR form codes: '8-K' or '10-K,10-Q'
  2. Join multi-select values with ',' and validate each token is a form code before submitting
  3. Omit forms entirely when no form filter is wanted — the filter is optional

Example fix

// before — wrong delimiter from a multi-select
forms: selectedForms.join(';')

// after — documented delimiter
forms: selectedForms.join(',')
Defensive patterns

Strategy: validation

Validate before calling

// mirror the comma-separated form-list contract
function normalizeForms(forms?: string): string | null {
  if (!forms?.trim()) return '';
  const parts = forms.split(',').map((f) => f.trim()).filter(Boolean);
  const ok = parts.length > 0 && parts.every((f) => /^[0-9A-Z-]+$/i.test(f));
  return ok ? parts.join(',') : null;
}
const forms = normalizeForms(rawForms);
if (forms === null) throw new ClientError('forms must be like "8-K" or "10-K,10-Q"');

Type guard

function isFormsViolation(body: unknown): boolean {
  const v = (body as { violations?: { field?: string }[] })?.violations;
  return Array.isArray(v) && v.some((x) => x.field === 'forms');
}

Try / catch

try {
  await searchSecFilings({ query, forms });
} catch (e) {
  if (e instanceof HttpError && e.status === 400) {
    const v = (e.body as { violations?: { field?: string }[] }).violations ?? [];
    // forms violations may arrive batched with date violations — fix all before resending
    if (v.some((x) => x.field === 'forms')) return fixFormsInput();
  }
  throw e;
}

Prevention

When it happens

Trigger: forms='8-K;10-Q' (semicolon separator); forms='8K' in a shape the normalizer rejects; forms='all' or a free-text value like 'annual reports'; trailing separators/garbage tokens like '10-K,,,financials'.

Common situations: UI multi-select joined with the wrong delimiter; users typing friendly form names; hardcoded form lists that drifted from EDGAR's form taxonomy.

Related errors


AI-assisted analysis of koala73/worldmonitor@eeab0a219f (2026-08-21). Data as JSON: /api/errors/0c5fe9e759f6bbf5. Report an issue: GitHub.