MCP fail-fast abort + lint clean: riksdag-regering unavailability causes hard exit#453
Merged
MCP fail-fast abort + lint clean: riksdag-regering unavailability causes hard exit#453
Conversation
…cp flag) Co-authored-by: pethers <[email protected]>
Copilot
AI
changed the title
[WIP] Add fail-fast abort for MCP client on server unavailability
MCP client: Add fail-fast abort when riksdag-regering MCP server is unavailable
Feb 23, 2026
…ines 500-514) Co-authored-by: pethers <[email protected]>
Copilot
AI
changed the title
MCP client: Add fail-fast abort when riksdag-regering MCP server is unavailable
MCP fail-fast: abort article generation when riksdag-regering MCP server is unavailable
Feb 23, 2026
…r, docs/coverage warnings) Co-authored-by: pethers <[email protected]>
Copilot
AI
changed the title
MCP fail-fast: abort article generation when riksdag-regering MCP server is unavailable
MCP fail-fast abort + lint clean: riksdag-regering unavailability causes hard exit
Feb 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR implements fail-fast behavior when the riksdag-regering MCP server is unavailable, preventing the pipeline from generating hollow articles with empty data. The implementation adds a --require-mcp flag (default true) that causes hard exits when the MCP server is unreachable after exhausting retry attempts.
Changes:
- Added
--require-mcpCLI flag to control fail-fast behavior (defaults to true) - Modified
getSharedClient()to throw an error and reset the shared client when MCP warm-up fails and requireMcp is true - Updated supplemental MCP fetch calls in
generateWeekAhead()to conditionally rethrow errors based on the requireMcp flag - Added comprehensive test coverage for MCP unavailability scenarios
- Fixed ESLint violations (no-useless-escape regex, improved error handling with cause)
- Added docs/coverage to ESLint ignore list
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| scripts/generate-news-enhanced.ts | Implements requireMcp flag, fail-fast logic in getSharedClient(), and conditional error rethrow in generateWeekAhead() supplemental fetches |
| scripts/data-transformers.ts | Fixed no-useless-escape ESLint warning in email regex pattern |
| eslint.config.js | Added docs/coverage/** to ignore list for auto-generated coverage reports |
| tests/generate-news-enhanced-mcp-abort.test.ts | New test file with dedicated coverage for MCP fail-fast scenarios across all generator types |
| tests/generate-news-enhanced-part1.test.ts | Added mock methods for supplemental fetches and new tests for error propagation |
| tests/generate-news-enhanced-part2.test.ts | Added mock methods for consistency with part1 test structure |
Signed-off-by: James Pether Sörling <[email protected]>
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Contributor
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Copilot AI
added a commit
that referenced
this pull request
Feb 23, 2026
- Take origin/main as base for data-transformers.ts, types/content.ts and tests/data-transformers.test.ts (which had landed PRs #453, #457, etc.) - Apply our PR changes on top: * extractPropRef: tighten regex to \d{4}\/\d{2}:\d+ (strict ID format) * groupMotionsByProposition: add export keyword; keep {grouped,independent} return type from main; replace inline lang-switches with L() labels * generateMotionsContent: use L(lang,'responsesToProp') and L(lang,'independentMotions') instead of 14-branch ternary chains * groupPropositionsByCommittee: new exported helper (Map<committeeKey,[...]>) * generatePropositionsContent: committee-grouped rendering (h3 per committee, h4 per prop when multi-committee; h3 per prop + Referred-to line otherwise) reuses byCommitteeGroup.size for policyImplicationsContext domainCount * ContentLabelSet: add responsesToProp and independentMotions fields * CONTENT_LABELS: add both new fields to all 14 language objects - Tests: add unit tests for exported helpers ({grouped,independent} API), label presence tests (28 tests for 2 keys × 14 langs), proposition grouping rendering tests; all 1674 tests passing across 39 test files Co-authored-by: pethers <[email protected]>
Copilot AI
added a commit
that referenced
this pull request
Feb 23, 2026
… take-main + apply) Take origin/main as clean base for data-transformers.ts, types/content.ts, tests/data-transformers.test.ts and sitemap.xml (main had landed PRs #453, #457, #469 etc.), then re-apply every PR-specific change on top: data-transformers.ts: - svSpan(): fix data-translate direction per translation workflow (lang!='sv' → data-translate="true"; lang='sv' → no marker) - PROP_REFERENCE_REGEX: strict \d{4}\/\d{2}:\d+ (was \S+) - PROP_FULL_REF_REGEX: non-greedy [^<]+? with HTML-tag lookahead - export groupMotionsByProposition (was private) - generateMotionsContent: replace 14-branch ternaries with L(lang,'responsesToProp') / L(lang,'independentMotions') - use PROP_FULL_REF_REGEX + svSpan() for proposition group heading - export groupPropositionsByCommittee (new) - generatePropositionsContent: committee-grouped rendering (h3+h4 when multi-committee; h3+referredLine when single-committee) - Add responsesToProp + independentMotions to all 14 language objects scripts/types/content.ts: - Add responsesToProp: string; independentMotions: string to ContentLabelSet tests/data-transformers.test.ts: - Import groupMotionsByProposition and groupPropositionsByCommittee - Fix 8 existing svSpan tests: flip data-translate expectations to match corrected svSpan() semantics - Add 5 unit tests for groupMotionsByProposition (strict-ID regex, fallback to title field, empty input, total-count invariant) - Add 5 unit tests for groupPropositionsByCommittee (organ/committee fallback, empty-string key, empty input, total-count invariant) - Add 28 label-presence tests (2 keys × 14 langs) - Add 4 rendering tests (single-committee h3, multi-committee h4, referredLine shown/hidden) All 1672 tests pass across 39 test files. Co-authored-by: pethers <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When the riksdag-regering MCP server is unreachable, the pipeline was silently continuing with empty data and generating hollow articles. Individual fetch calls swallowed errors via
.catch(() => []), producing fabricated article structures around no real parliamentary content.Fail-fast behaviour (
scripts/generate-news-enhanced.ts)--require-mcpflag (defaulttrue) — pass--require-mcp=falsefor local dev without a live servergetSharedClient()throws on warm-up failure whenrequireMcp=true; resetssharedClient=nullso subsequent retries work cleanly. Existing 3-attempt exponential backoff inMCPClient.request()exhausts first.generateWeekAhead()propagate errors — the three.catch(() => [])patterns forsearchDocuments,fetchWrittenQuestions,fetchInterpellationsnow conditionally rethrow:requireMcpexported for testabilityTests
tests/generate-news-enhanced-mcp-abort.test.ts— 5 tests: warm-up failure →{ success: false, error: /MCP server unavailable/i }across all generator types; verifiesrequireMcpdefaults totruetests/generate-news-enhanced-part1.test.ts—searchDocuments,fetchWrittenQuestions,fetchInterpellationsadded to mock; 2 new tests for supplemental-call propagation and call coveragetests/generate-news-enhanced-part2.test.ts— same mock additions for consistencyLint fixes
scripts/data-transformers.ts:1446no-useless-escape[...\-...]→[...-...]scripts/generate-news-enhanced.ts:391preserve-caught-errorthrow new Error('...', { cause: error })eslint.config.jsdocs/coverage/**to ignore list (auto-generated Istanbul files)Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.