Notes got an error: Can’t make container into type text.
dmd opened this issue · 3 comments
$ notes list
Account Folder Name Body
iCloud Notes freezer inventory freezer inventory 2 ground beef broccoli 4..
... lots of successful lines here and then ...
iCloud Notes zoo new england membership c.. 
Traceback (most recent call last):
File "/Users/dmd/venvs/general-python/bin/notes", line 8, in <module>
sys.exit(cli_main())
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/click/core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/click/core.py", line 1055, in main
rv = self.invoke(ctx)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/click/core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/click/core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/click/core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/macnotesapp/cli/cli.py", line 226, in list_notes
print_notes(notesapp)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/macnotesapp/cli/cli.py", line 368, in print_notes
folder = note.folder
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/macnotesapp/__init__.py", line 267, in folder
return str(self._run_script("noteGetContainer"))
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/macnotesapp/__init__.py", line 274, in _run_script
return run_script(script, self._account, self._id, *args)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/macnotesapp/script_loader.py", line 12, in run_script
return SCRIPT_OBJ.call(name, *args)
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/applescript/__init__.py", line 110, in call
return self._unpackresult(*self._script.executeAppleEvent_error_(evt, None))
File "/Users/dmd/venvs/general-python/lib/python3.9/site-packages/applescript/__init__.py", line 65, in _unpackresult
raise ScriptError(errorinfo)
applescript.ScriptError: Notes got an error: Can’t make container into type text. (-1700) app='Notes' range=6226-6230
This is an AppleScript error. macnotesapp uses a Python to Applescript bridge to interact with Notes (because Apple frustratingly provides no native API for doing so). Unfortunately, the Notes AppleScript interface is quite buggy and fickle so I'll have to try to reproduce this to figure out what's causing it. The error is caused when calling the AppleScript function noteGetContainer
which gets the parent folder of the note. This function uses some hackery to get around a bug in the Notes AppleScript interface.
I'll try to think about how to add some debugging output that might help identify the note in question which might then let me reproduce it.
I've added a dump
command to v0.4.0. Give this a try instead of list. It will dump all data on notes and when you get the error, we should be able to see the ID and name of the note (which gets printed before the body, which is what is causing the error) and thus do some further debugging.
I used list
on my entire Notes collection and was not able to reproduce the error.
In 0.4.0, neither list
nor dump
crashes!