koala73/worldmonitor · error

FAQ count must be 8-12, got ' + faqs.length

Error message

 FAQ count must be 8-12, got ' + faqs.length

What it means

applyComparisonNarrative merges page.faqs with narrative.extraFaqs and enforces an SEO-driven rule that each comparison page carries 8 to 12 FAQ entries. Pages outside that window are rejected so the FAQPage structured data and on-page FAQ block stay substantive.

Solutions

  1. Count page.faqs plus narrative.extraFaqs for the failing slug and adjust until the total is 8-12.
  2. Add FAQs to the narrative's extraFaqs to reach the minimum.
  3. Trim redundant FAQs (or move them to extraFaqs removal) to get under 12.
  4. Note duplicates will throw separately (duplicate FAQ question), so dedupe while adjusting.

Example fix

// before
faqs: [['Is it free?', 'Yes']] // 1 FAQ total
// after
faqs: [/* ensure 8-12 total after merging extraFaqs */
  ['Is it free?', 'Yes'], /* ...7 more unique questions */
];
Defensive patterns

Strategy: validation

Validate before calling

const total = page.faqs.length + (narrative.extraFaqs?.length ?? 0);
if (total < 8 || total > 12) throw new Error(`${page.slug}: ${total} FAQs, need 8-12`);

Type guard

const faqCountOk = (n) => Number.isInteger(n) && n >= 8 && n <= 12;

Try / catch

try {
  page = applyComparisonNarrative(page);
} catch (e) {
  if (String(e.message).includes('FAQ count must be 8-12')) {
    console.error('Adjust FAQ count for this page:', e.message);
  } else throw e;
}

Prevention

When it happens

Trigger: Running the comparison-pages build when (page.faqs.length + narrative.extraFaqs.length) is less than 8 or greater than 12 for any page slug.

Common situations: Adding a new comparison page with too few authored FAQs; appending extraFaqs without noticing the base page already has many; removing FAQs during copy review and dropping below the minimum.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of koala73/worldmonitor@7d06c8633d (2026-09-15). Data as JSON: /api/errors/c872733fc2fab115. Report an issue: GitHub.

Appendix: source

Thrown at scripts/build-comparison-pages.mjs:451

      ['Samdesk and Factal', 'dedicated social-signal verification desks'],
    ],
    whyWeWin: 'This is an intelligence layer, not a response capability. World Monitor sits alongside an assistance retainer as the always-on awareness feed: continuous multi-domain monitoring of conflict, aviation, maritime, and market signals that affect travelers, priced to cover the whole organization rather than only enrolled travelers. We cannot act on what we detect, and the page says so.',
    faqs: [
      ['Is World Monitor a Crisis24 alternative?', 'Not as a replacement. Crisis24 coordinates assistance; World Monitor is the always-on awareness feed that sits alongside an assistance retainer, covering conflict, aviation, maritime, and market signals. Buyers keep both: intelligence for awareness, assistance for response.'],
      ['Does World Monitor replace duty-of-care providers?', 'No. World Monitor has no assistance centers, no medical evacuation, and no mass notification, and it does not claim them. It covers the awareness layer that duty-of-care programs usually lack.'],
      ['What does travel risk intelligence cost?', 'World Monitor is free without signup, with Pro from $39.99/month. Assistance providers such as International SOS and Crisis24 negotiate enterprise retainers with undisclosed list pricing.'],
    ],
  },
];

function applyComparisonNarrative(page) {
  const narrative = COMPARISON_NARRATIVES[page.slug];
  if (!narrative) {
    throw new Error('Missing comparison narrative for ' + page.slug);
  }
  const faqs = [...page.faqs, ...(narrative.extraFaqs ?? [])];
  if (faqs.length < 8 || faqs.length > 12) {
    throw new Error(page.slug + ' FAQ count must be 8-12, got ' + faqs.length);
  }
  const faqNames = new Set();
  for (const [question] of faqs) {
    const key = String(question).trim().toLowerCase();
    if (faqNames.has(key)) {
      throw new Error(page.slug + ' duplicate FAQ question: ' + question);
    }
    faqNames.add(key);
  }
  const merged = { ...page, ...narrative, faqs };
  delete merged.extraFaqs;
  const whyBody = (merged.whyWeWinBody ?? []).join(' ').replace(/\s+/g, ' ').trim();
  if (!whyBody) {
    throw new Error(page.slug + ' is missing whyWeWinBody');
  }
  if (whyBody === merged.whyWeWin.replace(/\s+/g, ' ').trim()) {
    throw new Error(page.slug + ' whyWeWinBody must not repeat whyWeWin');
  }

View on GitHub (pinned to 7d06c8633d)