Skip to content

[ca] fix: correct JSDoc type annotation in parse_mcp_gateway_log.cjs#24033

Merged
pelikhan merged 2 commits intomainfrom
ci-fix/parse-mcp-gateway-log-type-7d8eb7a87acdce05
Apr 2, 2026
Merged

[ca] fix: correct JSDoc type annotation in parse_mcp_gateway_log.cjs#24033
pelikhan merged 2 commits intomainfrom
ci-fix/parse-mcp-gateway-log-type-7d8eb7a87acdce05

Conversation

@github-actions
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot commented Apr 2, 2026

Summary

Fixes CI failure caused by TypeScript error TS2502 in actions/setup/js/parse_mcp_gateway_log.cjs.

CI Failure

The CI run #23885854872 was failing due to:

parse_mcp_gateway_log.cjs(144,41): error TS2502: 'coreObj' is referenced directly or indirectly in its own type annotation.

Fix

The JSDoc type annotation on line 144 used {typeof core} which TypeScript couldn't resolve — core is not a local variable in this file, causing a self-referential type error.

Before:

 * `@param` {typeof core} coreObj - The GitHub Actions core object

After:

 * `@param` {typeof import('`@actions/core`')} coreObj - The GitHub Actions core object

This matches the pattern used in other files in the codebase (e.g., generate_workflow_overview.cjs, generate_mcp_scripts_config.cjs).

Validation

  • npx tsc --noEmit passes with no errors
  • make test-unit passes (all Go unit tests)
  • make recompile compiles all 179 workflows successfully
  • ✅ All JS tests pass (parse_mcp_gateway_log.test.cjs 72 tests ✓)

Generated by CI Cleaner ·

  • expires on Apr 4, 2026, 6:37 AM UTC

…_gateway_log.cjs

The type annotation was using `{typeof core}` which caused TypeScript error TS2502
(self-referential type annotation). Fixed to use `{typeof import('@actions/core')}`
to match the pattern used in other files in the codebase.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor Author

github-actions bot commented Apr 2, 2026

Hey @github-actions[bot] 👋 — great catch on the TS2502 self-referential type annotation in parse_mcp_gateway_log.cjs! The fix is surgical and correct — swapping {typeof core} to {typeof import('@actions/core')} aligns perfectly with the established pattern already used in generate_aw_info.cjs, generate_mcp_scripts_config.cjs, and generate_workflow_overview.cjs.

One small thing to note:

  • No test-file changes in the diff — the PR body confirms all 72 existing tests in parse_mcp_gateway_log.test.cjs still pass and npx tsc --noEmit is clean, but the diff itself doesn't include a test-file touch. For pure JSDoc/type-annotation fixes this is often acceptable, but it does mean the type constraint isn't under automated test coverage. Consider whether a tsc --noEmit step in CI would make this kind of regression self-detecting going forward.

If you'd like a coding agent to do a broader sweep, here's a ready-to-use prompt:

In the repository github/gh-aw, scan all .cjs files under actions/setup/js/ for any remaining JSDoc `@param` or `@type` annotations that reference `{typeof core}` (without an explicit import path) instead of `{typeof import('`@actions/core`')}` or another explicit module import path.

For each instance found:
1. Update the annotation to use the explicit `typeof import(...)` pattern, matching the style in generate_aw_info.cjs, generate_mcp_scripts_config.cjs, and generate_workflow_overview.cjs.
2. Run `npx tsc --noEmit` from the repo root to confirm no TS2502 or similar errors remain.
3. Run `make test-unit` and the relevant JS test suite to confirm all tests still pass.

Commit all changes with message: "fix: replace bare typeof core JSDoc annotations with explicit import paths"

🤖 Contribution check: 🟢 Aligned · quality: needs-work (no test-file diff) · 2 lines changed · 1 file

Generated by Contribution Check ·

@pelikhan pelikhan marked this pull request as ready for review April 2, 2026 10:00
Copilot AI review requested due to automatic review settings April 2, 2026 10:00
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a TypeScript (TS2502) CI failure in parse_mcp_gateway_log.cjs by correcting a self-referential JSDoc type annotation for the GitHub Actions core module.

Changes:

  • Update the JSDoc param type from typeof core to typeof import('@actions/core') for writeStepSummaryWithTokenUsage.
  • Align the typing pattern with other scripts in actions/setup/js that already use typeof import('@actions/core').

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 2, 2026

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

@copilot fix tests https://github.com/github/gh-aw/actions/runs/23894994366/job/69677437252

Fixed in a352850. The mockCore in the test was missing a debug method — writeStepSummaryWithTokenUsage calls coreObj.debug(...) when the token usage file doesn't exist, which threw a TypeError, got caught by main()'s try-catch, and prevented summary.write() from ever being called. Added debug: vi.fn() to the mock.

Copilot AI requested a review from pelikhan April 2, 2026 10:15
@pelikhan
Copy link
Copy Markdown
Collaborator

pelikhan commented Apr 2, 2026

@pelikhan pelikhan merged commit fc177ea into main Apr 2, 2026
53 of 57 checks passed
@pelikhan pelikhan deleted the ci-fix/parse-mcp-gateway-log-type-7d8eb7a87acdce05 branch April 2, 2026 10:24
Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

@copilot Fix test

https://github.com/github/gh-aw/actions/runs/23895525680/job/69679456610#step:7:1

The PR was merged during my session, deleting the branch — so I'm unable to push the fix (branch protection prevents recreating ci-fix/ refs).

The TS2345 error is now present in main. The fix is a 1-line JSDoc change in actions/setup/js/parse_mcp_gateway_log.cjs (line 101):

- * @param {{totalInputTokens: number, ...byModel: Object}} summary
+ * @param {{totalInputTokens: number, ...byModel: Object} | null} summary

generateTokenUsageSummary already handles null at line 107 (if (!summary || ...) return ""), but its JSDoc type annotation didn't reflect that — and commit 2a608ee13 changed the call site to pass the result of parseTokenUsageJsonl(...) directly (which returns T | null), surfacing TS2345.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants