Skip to content

Comments

fix: accurate sources list and safe slug in generate-news-enhanced.ts#442

Merged
pethers merged 2 commits intonews-generation/weekly-review-2026-02-22-25732d3df5a3d00ffrom
copilot/sub-pr-433
Feb 22, 2026
Merged

fix: accurate sources list and safe slug in generate-news-enhanced.ts#442
pethers merged 2 commits intonews-generation/weekly-review-2026-02-22-25732d3df5a3d00ffrom
copilot/sub-pr-433

Conversation

Copy link
Contributor

Copilot AI commented Feb 22, 2026

Two bugs in generate-news-enhanced.ts identified by code review.

Changes

  • Remove search_anforanden from week-ahead sourcesgenerateWeekAhead() never calls client.searchSpeeches(), so the source was a false declaration. Removed to keep declared MCP tools in sync with actual calls.

  • Guard against empty topSlug — Titles composed entirely of non-ASCII characters (e.g. Swedish Å/Ä/Ö) produce an empty string after the ASCII-only sanitization regex, which would propagate an invalid slug into breaking-news generation. Added || 'news' fallback:

// Before — empty string possible for non-ASCII titles
const topSlug = topDoc
  ? ((topDoc['titel'] || 'news')
      .toLowerCase()
      .replace(/[^a-z0-9\s-]/g, '')  // strips all Å/Ä/Ö → ""
      .replace(/\s+/g, '-')
      .slice(0, 40))
  : 'news';

// After — IIFE with explicit fallback
const topSlug = topDoc
  ? (() => {
      const cleaned = (topDoc['titel'] || 'news')
        .toLowerCase()
        .replace(/[^a-z0-9\s-]/g, '')
        .replace(/\s+/g, '-')
        .slice(0, 40);
      return cleaned || 'news';
    })()
  : 'news';

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Update weekly review for Feb 15-22 2026 parliamentary activity fix: accurate sources list and safe slug in generate-news-enhanced.ts Feb 22, 2026
Copilot AI requested a review from pethers February 22, 2026 16:46
@pethers pethers marked this pull request as ready for review February 22, 2026 16:52
@pethers pethers merged commit 0d59f24 into news-generation/weekly-review-2026-02-22-25732d3df5a3d00f Feb 22, 2026
@pethers pethers deleted the copilot/sub-pr-433 branch February 22, 2026 16:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants