Skip to content

[Bug]: agent core: dynamic import uses raw backslash path on Windows, producing invalid file:// URL #612

Description

@Sertug17

Affected package or area

@sapiom/agent-core load.ts (loadDefinition) and check.ts (check)

Affected version, release, or commit

latest main (3cbe957)

Environment

Node.js >= 18, Windows (or WSL with Windows paths); path.join returns backslash-separated paths

Minimal reproduction and steps

  1. On Windows, run sapiom run or sapiom check on any agent project
  2. Internally, loadDefinition/check calls:
    await import(file://${bundlePath}?t=${Date.now()})
    where bundlePath is e.g. C:\Users...\definition.mjs
  3. The resulting URL is invalid: file://C:\Users...\definition.mjs

Expected behavior

Dynamic import succeeds on Windows. pathToFileURL('C:\Users...\definition.mjs') correctly produces file:///C:/Users/.../definition.mjs

Actual behavior

Import throws ERR_INVALID_URL or MODULE_NOT_FOUND because the backslash path produces a malformed file:// URL, e.g.:

file://C:\Users\serhat\AppData\Local\Temp\sapiom-...\definition.mjs?t=1234567890

Logs, screenshots, and additional context

Fix: import { pathToFileURL } from "node:url" and use
${pathToFileURL(bundlePath).href}?t=${Date.now()}

Affected lines:

  • load.ts line 69-70
  • check.ts line 200-201

Acknowledgements

  • I searched existing open and closed issues for this problem.
  • This report does not describe a suspected security vulnerability; I will use the Security Policy for private reporting.
  • I removed secrets, credentials, personal data, and other sensitive information from this report.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingneeds-triageAwaiting maintainer review and classification

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions