Skip to content

Fix ESM/CJS runtime failure in auto-answer-issues workflow#5846

Merged
trwalke merged 2 commits intotrwalke/addGhActionForIssuesfrom
copilot/sub-pr-5836-ba99b67b-899c-418e-8b81-2131caea6c2d
Mar 11, 2026
Merged

Fix ESM/CJS runtime failure in auto-answer-issues workflow#5846
trwalke merged 2 commits intotrwalke/addGhActionForIssuesfrom
copilot/sub-pr-5836-ba99b67b-899c-418e-8b81-2131caea6c2d

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 11, 2026

require("openai") fails at runtime under Node 20 because openai v4+ is ESM-only. Same issue applies to @octokit/rest v19+.

Changes proposed in this request

  • Moved require("openai") and require("@octokit/rest") inside the async main() function as dynamic import() calls — the same pattern used in prototype/msal-analyzer/server/services/logAnalyzer.js
// Before — breaks with ESM-only packages
const { Octokit } = require("@octokit/rest");
const { AzureOpenAI } = require("openai");

async function main() { ... }

// After — works regardless of CJS/ESM package format
async function main() {
  const { Octokit } = await import("@octokit/rest");
  const { AzureOpenAI } = await import("openai");
  ...
}

Testing
No automated tests apply to workflow files. Validated locally that both packages load correctly via dynamic import() under Node 20.

Performance impact
None.

Documentation

  • All relevant documentation is updated.

🔒 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.

…in workflow

Co-authored-by: trwalke <30090357+trwalke@users.noreply.github.com>
@trwalke trwalke marked this pull request as ready for review March 11, 2026 22:25
@trwalke trwalke requested a review from a team as a code owner March 11, 2026 22:25
@trwalke trwalke merged commit a8430e1 into trwalke/addGhActionForIssues Mar 11, 2026
3 checks passed
Copilot AI changed the title [WIP] [WIP] Address feedback on auto-answering issues GitHub Actions workflow Fix ESM/CJS runtime failure in auto-answer-issues workflow Mar 11, 2026
@trwalke trwalke deleted the copilot/sub-pr-5836-ba99b67b-899c-418e-8b81-2131caea6c2d branch March 11, 2026 22:25
Copilot stopped work on behalf of trwalke due to an error March 11, 2026 22:25
bgavrilMS pushed a commit that referenced this pull request Mar 19, 2026
…workflow (#5846)

* Initial plan

* Fix ESM/CJS issue: use dynamic import() for openai and @octokit/rest in workflow

Co-authored-by: trwalke <30090357+trwalke@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: trwalke <30090357+trwalke@users.noreply.github.com>
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