Skip to content

Conversation

@Drarig29
Copy link
Contributor

@Drarig29 Drarig29 commented Jan 5, 2026

What and why?

Closes #2025

This PR fixes an ERR_UNSUPPORTED_ESM_URL_SCHEME error on Windows when importing plugins (be it built-in or not):

2026-01-05T17:34:23.293Z plugins Resolving submodule: @datadog/datadog-ci-plugin-sarif/commands/upload
2026-01-05T17:34:23.294Z plugins Resolved to: D:\a\datadog-ci\datadog-ci\.yarn\__virtual__\@datadog-datadog-ci-plugin-sarif-virtual-060a2f5b79\5\C:\Users\runneradmin\AppData\Local\Yarn\Berry\cache\@datadog-datadog-ci-plugin-sarif-file-626410fb6d-10c0.zip\node_modules\@datadog\datadog-ci-plugin-sarif\dist\commands\upload.js
2026-01-05T17:34:23.294Z plugins Importing submodule: D:\a\datadog-ci\datadog-ci\.yarn\__virtual__\@datadog-datadog-ci-plugin-sarif-virtual-060a2f5b79\5\C:\Users\runneradmin\AppData\Local\Yarn\Berry\cache\@datadog-datadog-ci-plugin-sarif-file-626410fb6d-10c0.zip\node_modules\@datadog\datadog-ci-plugin-sarif\dist\commands\upload.js
2026-01-05T17:34:23.302Z plugins Error in executePluginCommand: Error [ERR_UNSUPPORTED_ESM_URL_SCHEME]: Only URLs with a scheme in: file, data, and node are supported by the default ESM loader. On Windows, absolute paths must be valid file:// URLs. Received protocol 'd:'
    at throwIfUnsupportedURLScheme (node:internal/modules/esm/load:241:11)
    at defaultLoad (node:internal/modules/esm/load:132:3)
    at nextLoad (node:internal/modules/esm/hooks:864:28)
    at load$1 (file:///D:/a/datadog-ci/datadog-ci/.pnp.loader.mjs:1521:12)
    at nextLoad (node:internal/modules/esm/hooks:864:28)
    at Hooks.load (node:internal/modules/esm/hooks:451:26)
    at MessagePort.handleMessage (node:internal/modules/esm/worker:196:24)
    at [nodejs.internal.kHybridDispatch] (node:internal/event_target:831:20)
    at MessagePort.<anonymous> (node:internal/per_context/messageport:23:28) {
  code: 'ERR_UNSUPPORTED_ESM_URL_SCHEME'
}

How?

  • Use url.pathToFileURL(absolutePath) with await import()
  • Add e2e tests for Windows
  • Add missing unit test

While we could replace await import() with require(), it's better to avoid using require() when possible to ease any future migration to ESM-only (although not planned yet).

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)

@Drarig29 Drarig29 added datadog-ci For PRs spanning multiple commands, and repo-wide changes guild-project Related to a project lead by the #datadog-ci-guild labels Jan 5, 2026
@Drarig29 Drarig29 marked this pull request as ready for review January 5, 2026 18:38
@Drarig29 Drarig29 requested a review from a team as a code owner January 5, 2026 18:38
@Drarig29 Drarig29 force-pushed the corentin.girard/SYNTH-23730/fix-import-windows branch from 5d67a1c to 035da90 Compare January 6, 2026 09:56
@Drarig29 Drarig29 merged commit 5fa3510 into master Jan 7, 2026
26 checks passed
@Drarig29 Drarig29 deleted the corentin.girard/SYNTH-23730/fix-import-windows branch January 7, 2026 11:15
@ava-silver ava-silver mentioned this pull request Jan 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

datadog-ci For PRs spanning multiple commands, and repo-wide changes guild-project Related to a project lead by the #datadog-ci-guild

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to upload sarif

3 participants