papis icon indicating copy to clipboard operation
papis copied to clipboard

Ensure refs are unique on export

Open alexfikl opened this issue 1 year ago • 3 comments

In general, we do not enforce that ref is unique in a library. However, when exporting to various formats, we should ensure that all the documents have a unique ref.

This should apply to

  • [ ] BibTeX
  • [ ] Typst / Hayagriva

xref https://github.com/papis/papis/discussions/935

alexfikl avatar Nov 05 '24 11:11 alexfikl

Hmm this is somewhat related to #988, #1038

Should we make export error out on:

  • having many docs with same ref key
  • appending duplicates

?

tuurep avatar Jul 07 '25 22:07 tuurep

Should we make export error out on:

I'm not sure what a good behavior would be here, since you can always delete/rename them after the fact if you need them to be unique. From what I can tell:

  • You can export things to use them in a TeX documents, which will complain about duplicates.
  • You can export things just to have a backup, in which case duplicate refs don't matter that much.

So maybe a warning would be appropriate?

This also raises the issue of what to do on --append, since ensuring no duplicates means we need to read the existing file in, check it, possibly fix it, append the new documents, and write it back out.

alexfikl avatar Jul 08 '25 06:07 alexfikl

Could we leverage papis doctor functionality for this? Maybe this could be enabled by setting auto-doctor to true or with a --auto-doctor flag (though in this case it would just check the refs?).

Somewhat relatedly, I think we might eventually want to have auto-doctor default to true

jghauser avatar Jul 08 '25 08:07 jghauser