Skip to content

Fix vault fallback when Datacore returns no results#9

Open
NathanSkene wants to merge 1 commit into
DiscourseGraphs:mainfrom
NathanSkene:codex/datacore-empty-index-fallback
Open

Fix vault fallback when Datacore returns no results#9
NathanSkene wants to merge 1 commit into
DiscourseGraphs:mainfrom
NathanSkene:codex/datacore-empty-index-fallback

Conversation

@NathanSkene

Copy link
Copy Markdown

Summary

  • preserve Datacore as the first-choice query engine
  • fall back to Obsidian's vault and metadata cache when Datacore is unavailable, throws, or returns an empty query universe
  • apply the fallback consistently to node title search, compatible-node search, ID lookup, imported-node lookup, and node type/instance enumeration

Problem

When Datacore is loaded but its index is empty or stale, its query API can return an empty array for discourse nodes that already exist in Obsidian's metadata cache. QueryEngine treated that as an authoritative empty result. The Discourse Context panel consequently showed no existing relationships, and the relation picker could not find compatible nodes.

This also bypassed the repository's documented Datacore-first-with-vault-fallback convention.

Validation

  • exercised a regression harness with a mocked Datacore API returning []
  • verified title search, compatible-node search, node ID lookup, and node type/instance enumeration fall back correctly
  • ran node --check main.js
  • ran git diff --check
  • live-tested in Obsidian 1.12.7 with Datacore 0.1.29 and Discourse Graph 1.5.0:
    • a Topic root resolved its four existing contains relationships after reload
    • the relation picker found the expected Question node by title

The committed main.js bundle is updated alongside the TypeScript source so the fix is directly testable as an installed plugin.

@mdroidian

Copy link
Copy Markdown
Member

@NathanSkene Thank you for the contribution!

A couple issues:

  1. When Datacore is loaded but its index is empty or stale

Is this problem reproducible? Stated differently, what are the criteria that result in Datacore being loaded but it's index being empty or stale?

Also, is there a direct check we could do for this, rather than relying on just empty results? I would rather avoid running duplicate queries in the case of no results.

  1. Unfortunately this repo is just a generated distribution of the Discourse Graphs Obsidian plugin. Source code is maintained in the Discourse Graphs monorepo.

Would you be able to close this pull request and open a new pull request there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants