Skip to content

Breaking change in webUtils.getPathForFile() (maybe due to new MacOS filesystem security?), File object on drag/drop event fails to resolve absolute path (still works with <input type="file">) #44600

Closed

Description

@danielweck

Preflight Checklist

Electron Version

33.2.0

What operating system(s) are you using?

macOS

Operating System Version

Sequoia 15.1 (maybe older versions too)

What arch are you using?

x64

Last Known Working Electron version

No response

Expected Behavior

File object on drag/drop event should resolve to absolute path using webUtils.getPathForFile() (like <input type="file">)
(maybe due to new MacOS filesystem security?),

Actual Behavior

File object on drag/drop event resolves to empty absolute path when using webUtils.getPathForFile().
<input type="file"> still works fine, this seems to be a breaking change that applies to Electron versions [30...33] and probably due to some MacOS filesystem security (?) as this was working at some point before I upgraded to Sequoia 15.1

Testcase Gist URL

No response

Additional Information

I am trying to build a repro test case using Electron Fiddle...

Activity

  1. moved this to 👀 Unsorted Items in 33-x-yon Nov 8, 2024
  2. danielweck commented on Nov 8, 2024

    @danielweck
    Author

    Closing. I am unable to reproduce with ElectronFiddle, so the regression bug must have arisen from somewhere else. I will report back here when I figure this out! :)

    To test, I added the following event handlers in ElectronFiddle's DOMContentLoaded template:

    document.getElementsByTagName("body")[0].addEventListener("dragover", (event) => {
      event.preventDefault();
    });
    document.getElementsByTagName("body")[0].addEventListener("drop", (ev) => {
      ev.preventDefault();
        console.log(ev.dataTransfer.files[0].name);
        console.log(ev.dataTransfer.files[0].path);
        console.log(require("electron").webUtils.getPathForFile(ev.dataTransfer.files[0]));
    });
  3. danielweck commented on Nov 8, 2024

    @danielweck
    Author
  4. steveoh commented on Jan 23, 2025

    @steveoh

    console.log(require("electron").webUtils.getPathForFile(ev.dataTransfer.files[0]));

    I had to move this to the context bridge and pass the file through which is now null. Are you still able to run/import webUtils from the renderer? I'm not able to import that without error.

  5. added a commit that references this issue on Jul 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions