-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Description
Extension
https://www.raycast.com/raycast/apple-notes
Raycast Version
1.104.6
OS Version
26.2
Description
The get-note-content and update-note AI tools frequently fail with AppleScript error -1728 because the AI passes the note's UUID (ZIDENTIFIER) instead of the x-coredata ID that AppleScript requires.
The search-notes tool returns notes with two different ID fields:
id/noteId: the x-coredata format, e.g.x-coredata://81243823-DC1E-4D85-81EC-3C075E135B4E/ICNote/p3910UUID: the ZIDENTIFIER from the database, e.g.5AEC22F4-7356-456E-9D0C-112466B97201
The get-note-content and update-note tools pass the received noteId directly into AppleScript:
tell application "Notes"
set theNote to note id "${noteId}"
return body of theNote
end tellAppleScript only accepts the x-coredata format. When the AI passes the UUID format (which it does unpredictably, since both are present in the search results and the tool schema gives no guidance), the call fails with:
Notes got an error: Can't get note id "5AEC22F4-7356-456E-9D0C-112466B97201". (-1728)
Suggested Fix
Two changes, ideally both applied:
a) Make the tools accept both ID formats. Before passing the noteId to AppleScript, check if it starts with x-coredata://. If not, resolve it via the SQLite database using the existing executeSQL utility:
// In helpers.ts
import { executeSQL } from "@raycast/utils";
const NOTES_DB = resolve(homedir(), "Library/Group Containers/group.com.apple.notes/NoteStore.sqlite");
export async function resolveNoteId(noteId: string): Promise<string> {
if (noteId.startsWith("x-coredata://")) {
return noteId;
}
const result = await executeSQL<{ id: string }>(
NOTES_DB,
`SELECT 'x-coredata://' || zmd.z_uuid || '/ICNote/p' || note.z_pk AS id
FROM ziccloudsyncingobject AS note
LEFT JOIN z_metadata AS zmd ON 1=1
WHERE note.zidentifier = '${noteId.replace(/'/g, "''")}'
LIMIT 1`,
);
return result?.[0]?.id ?? noteId;
}b) Improve the tool input schema. Update the noteId description in both tool Input types and in the extension's package.json instructions to steer the AI toward the correct format:
type Input = {
/** The x-coredata ID of the note (starts with 'x-coredata://'). Use the 'id' field from search results, NOT the 'UUID' field. */
noteId: string;
};Steps To Reproduce
- Use Raycast AI with the Apple Notes extension
- Ask it to retrieve the content of a specific note (e.g. "What's in my note called [note title]?")
- The AI calls
search-notes, gets results containing bothidandUUIDfields - The AI calls
get-note-contentwith the UUID instead of the x-coredata ID - AppleScript error -1728
This doesn't happen every time — it depends on which ID field the AI selects. But it's frequent enough to make the tool unreliable.__
Current Behaviour
When the AI passes the UUID format (e.g. 5AEC22F4-7356-456E-9D0C-112466B97201) instead of the x-coredata format, get-note-content and update-note fail with:
Notes got an error: Can't get note id "5AEC22F4-7356-456E-9D0C-112466B97201". (-1728)
The error occurs because AppleScript's Notes dictionary only accepts the x-coredata URI format for note IDs. Since search-notes returns both formats and the tool schema provides no guidance on which to use, the AI selects the wrong one unpredictably.
Expected Behaviour
get-note-content and update-note should reliably retrieve/update the correct note regardless of which ID format the AI passes. Either the tools should accept both ID formats (resolving UUIDs to x-coredata IDs before calling AppleScript), or the schema should clearly guide the AI to always use the id field (x-coredata format) from search-notes results.