seed-hypermedia / mintter

Mintter: an app for knowledge communities. Powered by the Hypermedia protocol.
https://mintter.com
Apache License 2.0
162 stars 11 forks source link

Bug: API error "missing owner for entity X after processing the timeline" #1599

Open ericvicenti opened 9 months ago

ericvicenti commented 9 months ago

Problem

In my RC app if I open hm://d/mxpdanwL7pDszrAzPBQUE3 then I get this error immediately

Screenshot 2024-01-23 at 10 40 11 AM

ericvicenti commented 9 months ago

I also see this issue on the #Project document when I have citations panel open

https://hyper.media/d/4vHVRSx7XxmrxtV4fAcVNg?v=bafy2bzacebb6zte5tall5nawb2t4bqg6dsxm6yv45puuthk66cflip7prgbz2

ericvicenti commented 9 months ago

Verified that the issue happens after restart and also happens after re-launching the app

burdiyan commented 9 months ago

I don't see this happening with https://hyper.media/d/4vHVRSx7XxmrxtV4fAcVNg?v=bafy2bzacebb6zte5tall5nawb2t4bqg6dsxm6yv45puuthk66cflip7prgbz2 although I do have some other docs when this is happening.

As weird as it might sound, this error is returned when we don't have any changes for the requested documents. I have few docs that are embedded in other docs (maybe in very old changes), but I don't have the actual data for the embedded doc (why? I don't know). So when you'd ask for changes about a document we don't have changes for, we'd return this weird error (because we assume that after processing the changes we can lookup the ID of the owner, but we can't, because we actually haven't processed any changes, but we didn't realize that).

So my question is whether you'd prefer the GetEntityTimeline call to return an error in this case, like "no changes for the requested entity", or you'd prefer a successful response with an empty set of changes? @ericvicenti

ericvicenti commented 9 months ago

how is it possible to have a document without any changes?

Generally it is better to avoid errors and use empty responses, because the front end code to handle errors is kind of a pain

Do you have this document: hm://d/mxpdanwL7pDszrAzPBQUE3 and can you send me a screenshot?

burdiyan commented 9 months ago

A document without changes can happen very easily. Whenever you've learned about a document from a change of any other document (via an embed, link, or otherwise), and for some reason the other peer didn't give you the changes for this other document.

Can also happen for docs fetched via the DHT lookup. You get the doc, but you don't get the reference materials. The reference can be in some older change, and may not be visible anymore, so the frontend wouldn't fire another GetPublication for the reference to get (because it's not visible in the latest version). So you end up having a link to a document, without having any data about this other document, but most of the time it's OK, because this reference is not visible anymore. It is visible for the listCitations call though.

burdiyan commented 9 months ago

Anyway, I can return an empty response for documents with no changes when asked for their timeline. Don't know if you need to do anything extra to work with this kind of empty response.

burdiyan commented 9 months ago

OK. I did this in main. Please check if it works for you to close the issue. I didn't cherry-picked this into the release, not sure if you want it there.