giovannicoppola/zothero

'utf-8' codec can't decode byte 0xae in position 4998: invalid start byte

Closed this issue · 3 comments

[4:07:47.828 pm] Logging Started...
[4:07:55.542 pm] ZotHero[Script Filter] Queuing argument ''
[4:07:55.637 pm] ZotHero[Script Filter] Script with argv '' finished
[4:07:55.641 pm] STDERR: ZotHero[Script Filter] .
16:07:55 workflow.py:2093 DEBUG ---------- ZotHero (2.1.0) ----------
16:07:55 zh.py:684 DEBUG args={'--bibliography': False,
'--help': False,
'--paste': False,
'--style': None,
'--text': None,
'--title': None,
'': None,
'': None,
'': None,
'': '',
'<style>': None,
'': None,
'attachments': False,
'citations': False,
'clear': False,
'config': True,
'copy': False,
'fields': False,
'locale': False,
'notify': False,
'reindex': False,
'search': False,
'setvar': False,
'style': False}
16:07:55 config.py:86 DEBUG [config] datadir='/Users/Haydn/Documents/App data/Zotero'
16:07:55 workflow.py:2114 ERROR 'utf-8' codec can't decode byte 0xac in position 4837: invalid start byte
Traceback (most recent call last):
File "/Users/haydn/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.FBCAE54A-BC4B-4DA1-8B53-17097B04185F/lib/workflow/workflow.py", line 2107, in run
func(self)
File "/Users/haydn/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.FBCAE54A-BC4B-4DA1-8B53-17097B04185F/zh.py", line 698, in main
app = zothero.ZotHero(wf.cachedir, datadir, attachdir)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/haydn/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.FBCAE54A-BC4B-4DA1-8B53-17097B04185F/lib/zothero/core.py", line 63, in init
datadir, attachdir = read_config()
^^^^^^^^^^^^^
File "/Users/haydn/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.FBCAE54A-BC4B-4DA1-8B53-17097B04185F/lib/zothero/config.py", line 35, in read
return parse_prefs(p)
^^^^^^^^^^^^^^
File "/Users/haydn/Library/Application Support/Alfred/Alfred.alfredpreferences/workflows/user.workflow.FBCAE54A-BC4B-4DA1-8B53-17097B04185F/lib/zothero/config.py", line 73, in parse_prefs
for line in fp:
File "", line 322, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xac in position 4837: invalid start byte
16:07:55 workflow.py:2116 INFO for assistance, see: https://github.com/giovannicoppola/zothero/issues
16:07:55 workflow.py:2136 DEBUG ---------- finished in 0.023s ----------
[4:07:55.643 pm] ZotHero[Script Filter] {
"items": [
{
"title": "Error in workflow 'ZotHero'",
"subtitle": "'utf-8' codec can't decode byte 0xac in position 4837: invalid start byte",
"valid": false,
"icon": {
"path": "/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/AlertStopIcon.icns"
}
}
]
}

Hi,

Saw a few other posts like this that have been closed, but it didn't look there has been a solution?

Cheers,

I ran into the same issue. For me, the problem was a specific configuration parameter of Zotero. I've reseted its value and it now works. It may stop working once Zotero is setting this value again.

The parameter is extensions.zotero.recentSaveTargets and it was set to user_pref("extensions.zotero.recentSaveTargets", "[{\"id\":\"C63\",\"sessionID\":\"6CDnfGWC\"},{\"id\":\"C98\",\"sessionID\":\"3O4u4vZS\"},{\"id\":\"C101\",\"sessionID\":\"Zu8qBKaA\"},{\"id\":\"L1\",\"sessionID\":\"GkRFxMUF\"},{\"id\":\"L1\",\"sessionID\":\"abkkc5U3\"},{\"id\":\"L1\",\"sessionID\":\"BP6uoyVB\"},{\"id\":\"L1\",\"sessionID\":\"NWEc3Dyt\"}]");
The file on my machine is in ~/Library/Application Support/Zotero/Profiles/<some-profile>/prefs.js.

I tried reading this file line by line myself with only 3 lines of plain Python and it failed with the same utf-8 codec error:

path = "~/Library/Application Support/Zotero/Profiles/<some-profile>/prefs.js"
with open(path) as fp:
     for line in fp:
         line.strip() # fails for the line in question

I set the value to user_pref("extensions.zotero.recentSaveTargets", ""); (close Zotero before) and ZotHero worked. Honestly, I am not quite sure about the consequences of resetting this value but it seemed safe to me.

@timtroendle

Nice find! This worked for me too.