koala73/worldmonitor · error · Error

company claim type is invalid

Error message

company claim type is invalid

What it means

Contract validation error from normalizeCompanyClaimInput: input.type is not a key in the claim-type map. The lookup uses hasOwnProperty specifically so inherited properties like '__proto__', 'constructor', or 'toString' do not pass as valid types — a prototype-pollution hardening measure.

Source

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

export interface CompanyClaimInput {
  type: string;
  value: string;
}

export interface NormalizedCompanyClaimInput {
  type: CompanyClaimType;
  value: string;
}

export function normalizeCompanyClaimInput(input: CompanyClaimInput): NormalizedCompanyClaimInput {
  if (!input || typeof input !== 'object') throw new Error('company claim is required');
  // Own-property lookup: a plain object literal inherits `__proto__`, `constructor`,
  // `toString`, etc., and a truthiness check would let those through as a "valid" type.
  const type = Object.prototype.hasOwnProperty.call(COMPANY_CLAIM_TYPE_BY_INPUT, input.type)
    ? COMPANY_CLAIM_TYPE_BY_INPUT[input.type]
    : undefined;
  if (!type) throw new Error('company claim type is invalid');

  let value: string;
  switch (type) {
    case 'alias':
      value = assertPlainText(input.value, 'claim.value', COMPANY_MONITORING_LIMITS.maxAliasBytes);
      break;
    case 'domain':
      value = normalizeDomain(input.value, 0);
      break;
    case 'legal_identifier':
      value = assertPlainText(input.value, 'claim.value', COMPANY_MONITORING_LIMITS.maxIdentifierBytes);
      break;
    case 'x_account_id':
      value = assertPlainText(input.value, 'claim.value', COMPANY_MONITORING_LIMITS.maxXAccountIdBytes);
      if (!X_ACCOUNT_ID.test(value)) throw new Error('invalid X account ID');
      break;
    case 'x_handle':
      value = normalizeXHandle(input.value, 0);

View on GitHub (pinned to eeab0a219f)

Solutions

  1. Use one of the supported claim type keys (e.g. alias, domain, legal_identifier, x_account_id, x_handle, location, customer_reference)
  2. Send type as a plain own-property string, not an inherited object key
Defensive patterns

Strategy: validation

When it happens

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