beanie
beanie copied to clipboard
[BUG] Slient invalid document link resolution
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.
Hi! Thank you for the issue. I'll think about the interface for this