Creating file bookmarks doesn't work anymore on macOS 15 Sequoia

Before updating to macOS 15 Sequoia, I used to be able to create file bookmarks with this code:

let openPanel = NSOpenPanel()
openPanel.runModal()
let url = openPanel.urls[0]
do {
    let _ = try url.bookmarkData(options: [.withSecurityScope])
} catch {
    print(error)
}

Now I get an error

Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key"

These are the entitlements:

com.apple.security.app-sandbox
com.apple.security.files.user-selected.read-write
com.apple.security.files.bookmarks.app-scope

Strangely, my own apps continued working, after updating to macOS 15 some days ago, until a few moments ago. Then it seems that all of a sudden my existing bookmarks couldn't be resolved anymore, and no new bookmarks could be created. What could be the problem?

Answered by DTS Engineer in 806097022

Yesterday I filed FB15258541.

Thank you, that was very helpful.

What you're hitting is bug in "ScopedBookmarksAgent" which can cause it hang if it happens to have been launched when the keychain was also locked (for example, late in the screen lock process). That bug is fixed as of macOS 15.1 beta 4.

If you're hitting it regularly during development, you can resolve the issue by killing ScopedBookmarksAgent (you may also need to kill and relaunch your app, depending on what state it ends up). On the user side, a log out (or reboot) should resolve the issue.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

I haven't had the issue since updating to macOS 15.1 and haven't got any more reports from users either, but I will update you if I do.

If this happens on macOS 15.1 or later, then please file a new bug create and create a new thread or post the bug number back here (if this happens "soon").

One thing to be aware of here is that a system component like this has a very straightforward API surface (give URL-> get Data) with a very complex underlying implementation (multiple daemons, framework layer, sandboxing, file system issues, etc.). That dynamic means that there's a huge variety of possible failure points... of which look exactly the same at the final API layer ("my bookmark doesn't work").

That makes new bugs particular important because you want to make sure the issue gets investigated quickly by highlighting exactly where/how/when the failure is occur ("15.1, SMB volume, on Tuesdays") and by ensuring that the investigation starts from a "clean" slate, not with the team which happened to be responsible for the previous issue.

The new thread is just a miniature version of the same dynamic, as I can't promise I won't miss an update on this thread if it happens a year from now 🙂.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Written by floorish in 813377022
I've received multiple reports from users that macOS 14.7.1 cannot create new bookmarks or resolve existing bookmarks.

Today I too was contacted by a user who updated from macOS 13 to 14.7.1 and was quite desperate since my app couldn't resolve or create bookmarks anymore. Restarting the Mac didn't help. Thankfully you already reported the same issue so I suggested to update to 15.1.1, which finally solved the issue.

Written by Nickkk in 815593022
Today I too was contacted by a user who updated from macOS 13 to 14.7.1 and was quite desperate since my app couldn't resolve or create bookmarks anymore. Restarting the Mac didn't help. Thankfully you already reported the same issue so I suggested to update to 15.1.1, which finally solved the issue.

So far it only seems to happen for users that update from macOS 13. Very strange!

I've received multiple confirmations that any of these solutions resolve the issue:

  • Create a new user account (old account will stay bugged)
  • Reset the macOS keychain for the (bugged) user account
  • Update to 15.1+

Resetting the keychain is a bit technical and may cause data loss, so I recommend users to contact Apple Support for help with that.

Written by floorish in 815622022
I've received multiple confirmations that any of these solutions resolve the issue: Create a new user account (old account will stay bugged) Reset the macOS keychain for the (bugged) user account Update to 15.1+

Thank you SO MUCH for this.

I've spent a TON of time investigating why, after updating from Ventura to Sonoma, Final Cut Pro 11 was being so terribly SLOW ( mainly when opening libraries and when closing the app ), even though FCP 10.8.1 worked fine! A clue pointing me towards this thread popped up, when I tried to use HandBrake to transcode a video and have encountered the very same problems as in FCP.

Handbrake's console listed the following:

[09:30:49] macgui: Failed to create bookmark: Error Domain=NSCocoaErrorDomain Code=256 "Failed to retrieve app-scope key" UserInfo={NSDebugDescription=Failed to retrieve app-scope key}

[09:30:49] macgui: Failed to create bookmark: Error Domain=NSCocoaErrorDomain Code=256 "Could not open() the item" UserInfo={NSURL=file:///Users/######/Library/Containers/fr.handbrake.HandBrake/Data/Movies/, NSDebugDescription=Could not open() the item}

The new user account also worked flawlessly but that was obviously not a solution.

Nothing I did helped ( and believe you me, I've tried a ton of stuff, from re-downloading the app via app store, through launching it via a sandbox, rosetta, changing the permissions, ownership, flags, permissions via tccutil etc. to changing the user password, Mac's name and so on ) until I have resetted the macOS keychain.

So if anybody else's looking for solution to apps suddenly being weirdly slow when f.ex opening files and/or when closing, this is it.

Does upgrading from macOS 13 to macOS 14.7.1 break the keychain?

Apparently so. I didn't do anything in particular when updating. I do recall that Software Update popped up an update for some XCode's tools - a version 1.0 and 1.1 - and I've installed only 1.1 though I'm not sure if this has anything to do with this.

In any case, thanks again!

I just had this issue again on my own Mac with macOS 15.2. My app had been active for a while and had been able to resolve bookmarks. Then suddenly when trying to create new bookmarks I got the usual error. Restarting the app solved the issue.

I've received multiple reports from users that macOS 14.7.1 cannot create new bookmarks or resolve existing bookmarks.

This is a known issue (r.140342863). In terms of diagnosing the issue, you'll see these two log messages from ScopedBookmarkAgent shortly before it exits:

ScopedBookmarkAgent: [com.apple.FileURL:scoped] copy_data_protection_agent_key: error -25300 fetching key for UID...

ScopedBookmarkAgent: [com.apple.FileURL:scoped] copy_migrated_agent_key: error inserting the agent key: -25299

I can't provide any specific information about if/when it will be fixed, but this is being treated as a very serious issue, given how critical the keychain is to the system.

I just had this issue again on my own Mac with macOS 15.2. My app had been active for a while and had been able to resolve bookmarks. Then suddenly when trying to create new bookmarks I got the usual error. Restarting the app solved the issue.

This is a totally different issue. I don't know what the specific issue might be, but these two elements:

  1. The app is running for a significant period of time.

  2. The app works fine after it's quit relaunched.

...typically indicate that there's an issue with how scoped bookmarks are being managed. Each scoped bookmark your app has "active" requires a corresponding in kernel resource and once your app reaches that limit, scoped resolution will stop working.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Written by DTS Engineer in 818239022
The app is running for a significant period of time.

I had launched the app at most a couple hours earlier. I had the app running for weeks before and never had this issue.

I had launched the app at most a couple hours earlier. I had the app running for weeks before and never had this issue.

OK. To clarify what I was said above, I'm not saying there isn't a system bug involved, as it's certainly possible there is one. What I'm saying is that whatever is going on doesn't sound like the same issue that this thread is about.

In terms of investigating your failure, I would probably do the following:

  1. Add logging to your app immediately before and immediately after the function call where you detect the failure, making sure those messages reach the console log.

  2. Test your app normally until the failure occurs again.

  3. After the failure occurs, trigger a sysdiagnose.

  4. Open the console log from the sysdiagnose and find the two logs messages your app printed for the failure (#1 above).

  5. Look at the system console messages between those two points and "see what happened".

However, if you find something you want help with, please post it as a new forum thread.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Another macOS 14.7.2 user contacted me with this issue. Angry that my app isn't "compatible with macOS". I told them to contact Apple support, but they just wouldn't listen. Anyway not sure if that would have helped, as Apple support usually tells people that they should contact the third party developer. Then, with two conflicting answers, the user believes that I refuse to help them.

Does nobody at Apple see how frustrating this is for us developers? Is there nothing you can do to mitigate the anger our users have towards us because of issues in your operating system? People apparently are more inclined to believe that the small third party developer is at fault. I even sent them a link to this topic to convince them that it's a known macOS issue, but not sure if they visited it or could even understand it. Would it be too much to ask for Apple to make public announcements about these issues that normal users can understand and that we can point them to when they direct their anger towards us?

Following up on this thread, I believe the final bugs around this issue are resolved in the following security updates:

macOS Sonoma  14.7.3 (23H417)
macOS Ventura 13.7.3 (22H417)

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

That is great! How about macOS Sequoia, which version is it fixed in there?

Great to see more updates on this bug! Still seeing it for Sequoia users as well so hopefully that's fixed there as well in the 15.3 release?

That is great! How about macOS Sequoia, which version is it fixed in there?

macOS Sequoia had fully resolved the issue as of macOS 15.2.

Great to see more updates on this bug! Still seeing it for Sequoia users as well so hopefully that's fixed there as well in the 15.3 release?

So, we need to be clear about what "it" actually is. Earlier in this thread you said:

I just had this issue again on my own Mac with macOS 15.2. My app had been active for a while and had been able to resolve bookmarks. Then suddenly when trying to create new bookmarks I got the usual error. Restarting the app solved the issue.

This is NOT the bug (r.140342863) this thread has been focused on. The key data point is here:

Restarting the app solved the issue.

The bug (r.140342863) simply cannot be recovered from like this.

Stating this clearly to try and clear up the confusion here, there was a specific security fix that created this bug (r.140342863) in macOS 15 and that fix was then back ported to macOS 13 and 14. The bug effectively broke all security scoped resolution. It should now be fully resolved in:

macOS Sequoia 15.2 (24C101)
macOS Sonoma  14.7.3 (23H417)
macOS Ventura 13.7.3 (22H417)

As a completely separate issue, there a variety of other ways security scoped bookmarks can fail. Notably, the pattern where:

  • They work fine in an app for an extended period of time.

  • They suddenly stop working.

  • They work fine again once the app quits and relaunches.

...is a common and long standing app bug, typically caused by the app slowly leaking security scope references inside the kernel. If you're experiencing that issue, then that's a question you should raise on a new forum thread. It is NOT the issue that this thread is about.

__
Kevin Elliott
DTS Engineer, CoreOS/Hardware

Creating file bookmarks doesn't work anymore on macOS 15 Sequoia
 
 
Q