Juris-M / zotero

Juris-M is a variant of the free and friendly Zotero research platform, with support for legal and multilingual materials.
https://juris-m.github.io
Other
75 stars 12 forks source link

Invalid jurisdiction value breaks citation formatting in Word #104

Closed georgd closed 3 years ago

georgd commented 3 years ago

A colleague reported issues with a document with badly formatted citations (no abbrevs applied) which from time to time warned

Zotero experienced an error updating your document. Would you like to view troubleshooting instructions?

I could track it down to two entries with invalid values in the Jurisdiction field (see invalidJurisdiction.docx — The style used is JM IBFD with page labels).

There were some troubles during troubleshooting (by breaking up the document in smaller chunks) because the error led to Juris-M not formatting any document until it was restarted. These are the steps:

  1. Open two Word documents, one with a faulty citation entry, one with only valid entries.
  2. In the faulty document in the Zotero tab hit Refresh, the error will pop up (hit Cancel or Yes or do nothing).
  3. Switch to the good document and hit Refresh -> nothing will happen.

Can anything be done about this? It caused confusion because we erroneously thought, most of the citations were invalid, when, after the first error, no more document chunks produced any correct output.

fbennett commented 3 years ago

Thanks for this, and sorry for the delay in responding. I'll take a look today and post back.

fbennett commented 3 years ago

Progress. It's trying to parse the invalid value in the Abbrevs Filter and crashing there:

TypeError: can't convert undefined to object AbbrevsFilter.prototype.installAbbrevsForJurisdiction

I was able to trigger the error by registering the human-readable form used for display as the underlying value of the jurisdiction field. There was a storage bug in Jurism, fixed some time ago, that set this value in the database. There is a remapping method in there that I applied elsewhere to untangle the mess this created, and we should be able to use it here as well to recover in most cases. Where the remapping fails, we can fall back to "us."

That will get things working again, but it's not ideal. The client will show the value in the jurisdiction field without a highlight or other indication that it is invalid. I'll look into providing a highlight on the field when the remapping fails, so that users will be guided to correct invalid records.

More later ...

fbennett commented 3 years ago

I have another task to cover this evening, but I'm making progress on this. I think the best approach may be to sniff the jurisdiction from the human-readable form and load that with a "us" fallback (to avoid the error), but flag human-readable DB entries with a yellow highlight, to encourage resetting them to get the correct internal value.

fbennett commented 3 years ago

Nearly there with fixes. While investigating, though, I encountered a nasty bug, where setting a valid jurisdiction without specifying a court triggers eternal thrashing. Definitely not something we want people to encounter. Once that's fixed, I should be able to tidy up and move on to the release.

georgd commented 3 years ago

Thanks, the new feature, marking invalid jurisdiction values, looks good.

fbennett commented 3 years ago

For those who might drive by this issue (and as a note to myself until this is documents), details of the fixes are at https://github.com/Juris-M/zotero/issues/105