Skip to content

Fix News Realtime Monitor timeout: track breaking news errors, enforce script timeouts#1047

Merged
pethers merged 12 commits into
mainfrom
copilot/debug-news-realtime-monitor
Mar 11, 2026
Merged

Fix News Realtime Monitor timeout: track breaking news errors, enforce script timeouts#1047
pethers merged 12 commits into
mainfrom
copilot/debug-news-realtime-monitor

Conversation

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Workflow run #22947592952 failed because the agent consumed the full 45-minute budget without calling a safe output tool. Two root causes: silent error swallowing in breaking news generation, and no timeout enforcement on script execution.

Bug fix: breaking news error tracking

The breaking case in generateNews() had two gaps in error tracking:

  1. Exception path: The catch block never incremented stats.errors, so thrown exceptions were silently swallowed. The catch block now also uses err instanceof Error ? err.message : String(err) to safely log any thrown value.
  2. Non-throwing failure path: generateBreakingNews() returns {success: false} on internal failures rather than throwing, so the try/catch alone was insufficient. Now the returned GenerationResult is captured and stats.errors is incremented when result.success === false.
const breakingResult = await generateBreakingNews({ ... });
if (!breakingResult.success) {
  console.error('❌ Breaking news generation failed:', breakingResult.error ?? 'unknown error');
  stats.errors++;
}

This matters because runCli() uses stats.errors > 0 to decide exit code 1 vs 0, which the agent uses to determine whether generation succeeded.

Timeout enforcement in workflow MD

  • Wrap generation script with timeout 1200 (20 min) to prevent indefinite hangs on slow MCP server
  • Wrap validation with timeout 300 (5 min)
  • Add elapsed-time guards before generation and validation phases
  • Tighten time budget cutoffs from 38/43 to 35/40 minutes
  • Add explicit "call safe output immediately" instructions at multiple decision points
  • On timeout (exit 124), only normalize SCRIPT_EXIT to 0 when NEW_ARTICLES is non-empty (partial content produced); keep the non-zero exit when timeout produces no content so the error/fallback path triggers correctly. A TIMED_OUT flag tracks timeout state separately from the exit code.

Scheduled run language default

For scheduled runs (empty github.event.inputs.languages), the workflow now defaults to en,sv (core languages) instead of all (14 languages). This matches the workflow description ("core languages EN, SV") and keeps generation within the time budget. Manual dispatch can still specify "all" for full 14-language generation. The time budget table text has been updated to reflect the new default.

Security: fix command injection in workflow bash

Replaced bash -c "$GENERATE_CMD" (which interpolated user-supplied LANG_ARG into a command string) with export LANG_ARG + single-quoted bash -lc '...--languages="$LANG_ARG"...'. The variable is now resolved from the environment inside the subshell, eliminating command injection risk from workflow dispatch input containing shell metacharacters.

Robustness: standalone-safe elapsed-time snippets

All elapsed-time check blocks now source /tmp/gh-aw/agent/timing.env and use : "${START_TIME:=$(date +%s)}" as a fallback, so they produce correct results even when run in a fresh shell without START_TIME set.

Tests

  • 4 new error handling tests in breaking-news.test.ts: null/undefined event data, mcpCalls on early failure, MCP tool failure resilience
  • 4 new focused tests in generate-news-breaking-errors.test.ts exercising generateNews() with articleTypes=['breaking']: verifies stats.errors is exactly 1 when generateBreakingNews() returns {success: false}, exactly 1 when getSharedClient() throws, exactly 0 on success, and that the error message is logged. Tests use fail-fast imports (no silent early returns) so import failures surface immediately rather than producing false passes.
Original prompt

This section details on the original issue you should resolve

<issue_title>[aw] News Realtime Monitor failed</issue_title>
<issue_description>### Workflow Failure

Workflow: News Realtime Monitor
Branch: main
Run: https://github.com/Hack23/riksdagsmonitor/actions/runs/22947592952
Pull Request: #1016

Action Required

Option 1: Debug using any coding agent

Use this prompt with any coding agent (GitHub Copilot, Claude, Gemini, etc.):

Debug the agentic workflow failure using https://raw.githubusercontent.com/github/gh-aw/main/debug.md

The failed workflow run is at https://github.com/Hack23/riksdagsmonitor/actions/runs/22947592952

Option 2: Assign this issue to Copilot

Assign this issue to Copilot using the agentic-workflows sub-agent to automatically debug and fix the workflow failure.

Option 3: Manually invoke the agent

Debug this workflow failure using your favorite Agent CLI and the agentic-workflows prompt.

[!TIP]
To stop a workflow from creating failure issues, set report-failure-as-issue: false in its frontmatter:

safe-outputs:
  report-failure-as-issue: false

Generated from News Realtime Monitor

  • expires on Mar 18, 2026, 11:04 AM UTC

Comments on the Issue (you are @copilot in this section)

Custom agent used: hack23-test-specialist
Expert in test strategy, test automation, coverage improvement, quality assurance, and implementing comprehensive testing across unit, integration, and E2E layers


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Copilot AI and others added 2 commits March 11, 2026 13:24
…nt workflow timeout

- Increment stats.errors when breaking news generation fails (was silently swallowed)
- Add 20-minute timeout wrapper to script execution in news-realtime-monitor.md
- Add elapsed time checks before generation and validation phases
- Add 5-minute timeout to validation script
- Tighten time budget (35/40 min cutoffs vs 38/43) with explicit safe output instructions
- Add error handling tests for breaking news module

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
Copilot AI changed the title [WIP] Debug workflow failure in News Realtime Monitor Fix News Realtime Monitor timeout: track breaking news errors, enforce script timeouts Mar 11, 2026
@github-actions github-actions Bot added documentation Documentation updates workflow GitHub Actions workflows ci-cd CI/CD pipeline changes testing Test coverage refactor Code refactoring news News articles and content generation agentic-workflow Agentic workflow changes labels Mar 11, 2026
@pethers pethers requested a review from Copilot March 11, 2026 13:44
@github-actions github-actions Bot added size-m Medium change (50-250 lines) labels Mar 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a failure mode in the “News Realtime Monitor” agent workflow by improving failure signaling for breaking-news generation and adding explicit time-budget enforcement in the workflow runbook to avoid exhausting the 45-minute execution window.

Changes:

  • Increment stats.errors when breaking-news generation throws, so runCli() can exit non-zero on failure.
  • Add timeout wrappers and elapsed-time guardrails to the news-realtime-monitor.md workflow instructions to prevent long-running/hanging script/validation steps.
  • Add unit tests covering breaking-news error handling paths (missing event data, MCP tool failures).

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
scripts/generate-news-enhanced/index.ts Tracks breaking-news exceptions by incrementing stats.errors to influence CLI exit code.
.github/workflows/news-realtime-monitor.md Adds elapsed-time checks and timeout wrappers around generation/validation steps to keep the agent within budget.
tests/news-types/breaking-news.test.ts Adds tests for early-failure behavior and resilience to MCP tool errors.

Comment thread scripts/generate-news-enhanced/index.ts Outdated
Comment on lines 153 to 166
} catch (err: unknown) {
console.error('❌ Error generating breaking news:', (err as Error).message);
stats.errors++;
}

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generateBreakingNews() returns a GenerationResult with success: false on internal failures (it catches and returns) rather than throwing. In that case this try/catch won’t run and stats.errors will still remain 0, so runCli() may exit 0 even though breaking generation failed. Capture the returned result and increment stats.errors (and log the error) when result.success === false.

Copilot uses AI. Check for mistakes.
Comment on lines +229 to +230
GENERATE_CMD="source scripts/mcp-setup.sh && npx tsx scripts/generate-news-enhanced.ts --types=breaking --languages=${LANG_ARG} --skip-existing"
timeout 1200 bash -c "$GENERATE_CMD"

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LANG_ARG can come directly from ${{ github.event.inputs.languages }} and may contain spaces (e.g. "en, sv"). In GENERATE_CMD, --languages=${LANG_ARG} will then be split into multiple arguments and break parsing. Quote/escape the languages argument in the generated command (e.g. ensure --languages receives exactly one shell token) and avoid constructing an unescaped shell string where possible.

Suggested change
GENERATE_CMD="source scripts/mcp-setup.sh && npx tsx scripts/generate-news-enhanced.ts --types=breaking --languages=${LANG_ARG} --skip-existing"
timeout 1200 bash -c "$GENERATE_CMD"
timeout 1200 bash -lc 'source scripts/mcp-setup.sh && npx tsx scripts/generate-news-enhanced.ts --types=breaking --languages="$LANG_ARG" --skip-existing'

Copilot uses AI. Check for mistakes.
Comment on lines +229 to +231
GENERATE_CMD="source scripts/mcp-setup.sh && npx tsx scripts/generate-news-enhanced.ts --types=breaking --languages=${LANG_ARG} --skip-existing"
timeout 1200 bash -c "$GENERATE_CMD"
SCRIPT_EXIT=$?

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This builds a shell command string that includes workflow-dispatch input (LANGUAGES_INPUTLANG_ARG) and executes it via bash -c. That pattern is vulnerable to command injection if the input contains shell metacharacters. Prefer invoking timeout/npx directly (no bash -c) and keep the user-supplied value only in a properly quoted argument (or validate it against an allow-list).

Copilot uses AI. Check for mistakes.
- `>= 38 min` → Stop generating, commit what you have, create PR immediately
- `>= 43 min` → STOP ALL WORK, call safe output immediately
**Hard cutoffs** — check elapsed time before EVERY phase:
```bash

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The elapsed-time snippet uses START_TIME directly, but if someone runs this block in a fresh shell without START_TIME set, Bash arithmetic will treat it as 0 and report an enormous elapsed time (epoch seconds), which can trigger incorrect “time budget exceeded” decisions. Consider sourcing /tmp/gh-aw/agent/timing.env (or re-initializing START_TIME) in the snippet so it’s safe to run standalone like the later generation/validation guards.

Suggested change
```bash
```bash
# Restore START_TIME if available so this snippet is safe to run standalone
if [ -f /tmp/gh-aw/agent/timing.env ]; then
. /tmp/gh-aw/agent/timing.env
fi
# Fallback: if START_TIME is still unset, initialize it to "now" to avoid huge elapsed times
: "${START_TIME:=$(date +%s)}"

Copilot uses AI. Check for mistakes.
@pethers

pethers commented Mar 11, 2026

Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

…nd injection, safe START_TIME

- Check generateBreakingNews() return value for success: false (not just exceptions)
- Fix command injection: export LANG_ARG and use single-quoted bash -lc instead of
  interpolating user input into a command string via bash -c
- Make elapsed-time snippet safe for standalone execution by sourcing timing.env
  and using : "${START_TIME:=$(date +%s)}" fallback
- Apply same START_TIME safety to generation and validation time checks

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all 4 review comments in 810e721:

  1. index.ts:153-166: Now captures the GenerationResult from generateBreakingNews() and increments stats.errors when result.success === false — covers both the non-throwing failure path and the exception path.
  2. news-realtime-monitor.md:229-231: Eliminated command injection risk by exporting LANG_ARG and using single-quoted bash -lc '...$LANG_ARG...' — the variable is resolved from the environment inside the subshell, never interpolated into a command string.
  3. news-realtime-monitor.md:229-230: $LANG_ARG is now properly double-quoted inside the single-quoted subshell (--languages="$LANG_ARG"), so spaces in the input won't split it.
  4. news-realtime-monitor.md:137: Elapsed-time snippet now sources timing.env and uses : "${START_TIME:=$(date +%s)}" fallback, so it's safe to run standalone. Same fix applied to the generation and validation time-check blocks.

@pethers pethers requested a review from Copilot March 11, 2026 14:54
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

timeout 1200 bash -lc 'source scripts/mcp-setup.sh && npx tsx scripts/generate-news-enhanced.ts --types=breaking --languages="$LANG_ARG" --skip-existing'
SCRIPT_EXIT=$?
if [ "$SCRIPT_EXIT" -eq 124 ]; then
echo "⚠️ Script timed out after 20 minutes — proceeding with whatever was generated"

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timeout returns exit code 124 on timeout, but this value is kept in SCRIPT_EXIT. A later decision point treats non-zero SCRIPT_EXIT + no new articles as a script error (manual fallback), which contradicts the note “proceeding with whatever was generated” and can waste time near the deadline. Consider normalizing SCRIPT_EXIT to 0 on 124 (soft failure) or updating the subsequent decision logic to treat 124 as a non-fatal timeout case.

Suggested change
echo "⚠️ Script timed out after 20 minutes — proceeding with whatever was generated"
echo "⚠️ Script timed out after 20 minutes — proceeding with whatever was generated"
# Treat timeout as soft failure to avoid triggering manual fallback if some content was produced
SCRIPT_EXIT=0

Copilot uses AI. Check for mistakes.
Comment on lines +215 to +226
if [ -z "$NEW_ARTICLES" ]; then
echo "No new breaking news articles were created."
export LANG_ARG

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For scheduled runs, ${{ github.event.inputs.languages }} is empty, so the snippet falls back to LANGUAGES_INPUT="all", which triggers 14-language generation and can significantly increase runtime. This conflicts with the workflow description (“core languages (EN, SV)”) and undermines the new time-budget enforcement. Consider defaulting the empty-input case to en,sv (or another explicit core preset) and reserving all for manual dispatch.

Copilot uses AI. Check for mistakes.
Comment on lines 153 to 170
@@ -160,8 +160,13 @@ export async function generateNews(): Promise<typeof stats> {
},
writeArticle: translatingWriteArticle,
});
if (!breakingResult.success) {
console.error('❌ Breaking news generation failed:', breakingResult.error ?? 'unknown error');
stats.errors++;
}
} catch (err: unknown) {
console.error('❌ Error generating breaking news:', (err as Error).message);
stats.errors++;
}

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The breaking-news path now increments stats.errors both when generateBreakingNews() returns { success: false } and when it throws. There are unit tests for generateNews() in tests/generate-news-enhanced-part2.test.ts, but none that exercise the breaking case (default articleTypes is ['week-ahead']), so this new exit-code-critical behavior isn’t covered. Add a focused test that forces articleTypes to include breaking and mocks generateBreakingNews() to return failure/throw, then asserts stats.errors increments.

Copilot uses AI. Check for mistakes.
@pethers

pethers commented Mar 11, 2026

Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

Copilot AI and others added 4 commits March 11, 2026 15:11
… breaking error tests

1. Normalize SCRIPT_EXIT to 0 on timeout (exit 124) to prevent manual
   fallback when partial content was produced
2. Default empty LANGUAGES_INPUT to 'en,sv' instead of 'all' for
   scheduled runs — matches workflow description and time budget
3. Add 4 focused tests for generateNews() breaking case:
   - stats.errors increments on {success: false}
   - stats.errors increments on thrown exception
   - stats.errors stays 0 on {success: true}
   - error message is logged from failed result

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…ide effects

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…l(1)

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…e writes

Use hoisted vi.mock('fs') instead of vi.spyOn() in beforeAll to ensure
filesystem mocking is active before the dynamic import triggers
generateNews() side effects.

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all 3 review comments across commits 22dbbfd943e813:

  1. news-realtime-monitor.md:241: Timeout (exit 124) now normalizes SCRIPT_EXIT to 0, preventing the manual fallback path from triggering when partial content was already produced.
  2. news-realtime-monitor.md:215-226: Empty LANGUAGES_INPUT (scheduled runs) now defaults to en,sv instead of all, keeping within the time budget. Manual dispatch can still specify "all" for 14-language generation.
  3. New test file tests/generate-news-breaking-errors.test.ts: 4 focused tests exercising the generateNews() breaking case — asserts stats.errors is exactly 1 when generateBreakingNews() returns {success: false}, exactly 1 when getSharedClient() throws, exactly 0 on success, and that the error message is logged. All 131 tests pass.

@pethers pethers requested a review from Copilot March 11, 2026 15:25
@github-actions github-actions Bot added the size-l Large change (250-1000 lines) label Mar 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 8 comments.

Comment on lines +137 to +138
if (!moduleExports) return;

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return means the test passes without executing assertions when moduleExports is null (e.g., if the import failed). Replace with an assertion or throw so the test fails when the module can’t be imported.

Copilot uses AI. Check for mistakes.
Comment on lines +148 to +149
if (!moduleExports) return;

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return means the test passes without executing assertions when moduleExports is null (e.g., if the import failed). Replace with an assertion or throw so the test fails when the module can’t be imported.

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +163
if (!moduleExports) return;

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return means the test passes without executing assertions when moduleExports is null (e.g., if the import failed). Replace with an assertion or throw so the test fails when the module can’t be imported.

Copilot uses AI. Check for mistakes.
Comment on lines +240 to +246
timeout 1200 bash -lc 'source scripts/mcp-setup.sh && npx tsx scripts/generate-news-enhanced.ts --types=breaking --languages="$LANG_ARG" --skip-existing'
SCRIPT_EXIT=$?
if [ "$SCRIPT_EXIT" -eq 124 ]; then
echo "⚠️ Script timed out after 20 minutes — proceeding with whatever was generated"
# Treat timeout as soft failure to avoid triggering manual fallback if some content was produced
SCRIPT_EXIT=0
fi

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The timeout handling normalizes exit code 124 to 0 unconditionally. If the script times out and produces no new articles, later logic will treat it like a clean “no events” run and may call noop instead of triggering the error/fallback path. Consider only treating timeout as a soft success when NEW_ARTICLES is non-empty (or track a separate TIMED_OUT flag and keep a non-zero exit when nothing was generated).

Copilot uses AI. Check for mistakes.
| Generate | 8–35 | Run `generate-news-enhanced.ts` script (handles all 14 languages) |
| Validate | 35–38 | Run `validate-news-generation.sh` |
| Commit+PR | 38–43 | `git add && git commit`, then `safeoutputs___create_pull_request` |
| Generate | 8–30 | Run `generate-news-enhanced.ts` script (handles all 14 languages) |

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The time budget table says the generation script “handles all 14 languages”, but this workflow now defaults scheduled runs to en,sv. This wording is likely to confuse operators/agents about expected runtime and output; consider aligning the table text with the new default behavior (core languages by default, “all” via manual dispatch).

Suggested change
| Generate | 8–30 | Run `generate-news-enhanced.ts` script (handles all 14 languages) |
| Generate | 8–30 | Run `generate-news-enhanced.ts` script (core languages by default; supports all 14 languages via \`languages=all\`) |

Copilot uses AI. Check for mistakes.
Comment thread scripts/generate-news-enhanced/index.ts Outdated
stats.errors++;
}
} catch (err: unknown) {
console.error('❌ Error generating breaking news:', (err as Error).message);

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this catch block, (err as Error).message can log undefined if a non-Error is thrown/rejected. Prefer using err instanceof Error ? err.message : String(err) to ensure a useful message is always logged.

Suggested change
console.error('❌ Error generating breaking news:', (err as Error).message);
console.error(
'❌ Error generating breaking news:',
err instanceof Error ? err.message : String(err),
);

Copilot uses AI. Check for mistakes.
moduleExports = await import('../scripts/generate-news-enhanced/index.js') as unknown as GenerateNewsModule;
} catch (e: unknown) {
console.error('Import failed:', e instanceof Error ? e.message : String(e));
moduleExports = null;

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test suite can silently pass if the module import fails: beforeAll catches the import error, sets moduleExports=null, and the individual tests then return early. That means these tests may provide a false sense of coverage. Prefer failing fast (e.g., rethrow in beforeAll or assert moduleExports is non-null at the start of each test).

Suggested change
moduleExports = null;
throw e;

Copilot uses AI. Check for mistakes.
Comment on lines +123 to +124
if (!moduleExports) return;

Copilot AI Mar 11, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This early return means the test passes without executing assertions when moduleExports is null (e.g., if the import failed). Replace with an assertion or throw so the test fails when the module can’t be imported.

Copilot uses AI. Check for mistakes.
@pethers

pethers commented Mar 11, 2026

Copy link
Copy Markdown
Member

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits March 11, 2026 15:51
…ion, safe error logging

1. Tests: replace silent early returns with `expect(moduleExports).not.toBeNull()`
   assertions; remove try/catch in beforeAll so import failures fail the suite
   immediately instead of silently passing all tests.

2. Workflow: only normalize timeout exit (124→0) when NEW_ARTICLES is non-empty;
   keep non-zero exit when timeout produces no content so the error/fallback path
   triggers correctly. Update time-budget table to reflect en,sv default.

3. index.ts: use `err instanceof Error ? err.message : String(err)` in catch block
   to avoid logging `undefined` for non-Error rejects.

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
…ort failure

Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>

Copilot AI commented Mar 11, 2026

Copy link
Copy Markdown
Contributor Author

@copilot apply changes based on the comments in this thread

Applied all 8 review comments in 014753120d74bc:

  1. generate-news-breaking-errors.test.ts:98: Removed try/catch in beforeAll — import failures now fail the suite immediately.
  2. generate-news-breaking-errors.test.ts:123,137,148,162: Replaced silent if (!moduleExports) return early returns with fail-fast assertions, then removed the now-redundant null checks since moduleExports is non-nullable.
  3. news-realtime-monitor.md:240-246: Timeout (exit 124) now only normalizes SCRIPT_EXIT to 0 when NEW_ARTICLES is non-empty. Tracks TIMED_OUT flag separately.
  4. news-realtime-monitor.md:132: Time budget table updated to reflect core-language default.
  5. index.ts:168: Catch block now uses err instanceof Error ? err.message : String(err) to avoid logging undefined.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 Lighthouse Performance Audit

Category Score Status
Performance 85/100 🟡
Accessibility 95/100 🟢
Best Practices 90/100 🟢
SEO 95/100 🟢

📥 Download full Lighthouse report

Budget Compliance: Performance budgets enforced via budget.json

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@pethers pethers marked this pull request as ready for review March 11, 2026 16:25
@pethers pethers merged commit 4e01559 into main Mar 11, 2026
20 checks passed
@pethers pethers deleted the copilot/debug-news-realtime-monitor branch March 11, 2026 16:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agentic-workflow Agentic workflow changes ci-cd CI/CD pipeline changes documentation Documentation updates news News articles and content generation refactor Code refactoring size-l Large change (250-1000 lines) size-m Medium change (50-250 lines) testing Test coverage workflow GitHub Actions workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] News Realtime Monitor failed

3 participants