beanie icon indicating copy to clipboard operation
beanie copied to clipboard

[BUG] Slient invalid document link resolution

Open thorin-schiffer opened this issue 1 year ago • 1 comments

Describe the bug When a document has a invalid link, fetch_links=True results in a silent non-resolution to the Link object. This is a hardly debuggable case if a collection of objects is fetched.

To Reproduce So if attribute requires a domain

class Domain(Document):
    ...

class Attribute(Document):
    ...
    domain: Link[Domain]
    ...

and the linked domain was removed, requesting a collection like await Attribute.all(fetch_links=True).to_list() will have both resolved and unresolved links to domain, which is hard to distinguish from await Attribute.all().to_list() without fetched links.

Expected behavior I would prefer an exception, but alternatively another type can be set, like UnresolvableLink, or None or Link instance with some flag.

thorin-schiffer avatar Feb 21 '24 10:02 thorin-schiffer

Hi! Thank you for the issue. I'll think about the interface for this

roman-right avatar Feb 26 '24 17:02 roman-right