Skip to content

fix: stop resolveMdLinks from breaking dataview links - #400

Merged
oleeskild merged 1 commit into
mainfrom
fix/dataview-links-404
Aug 11, 2026
Merged

fix: stop resolveMdLinks from breaking dataview links#400
oleeskild merged 1 commit into
mainfrom
fix/dataview-links-404

Conversation

@oleeskild

Copy link
Copy Markdown
Owner

Fixes #399

Problem

The resolveMdLinks filter shipped in 1.83.0 (#398) sent every dataview-generated link to /404. Two defects compounded:

  1. convertMdHrefs' anchor regex (<a\s[^>]*?href=") also matched the tail of data-href=". DataviewJS output contains Obsidian-rendered anchors like <a data-href="Folder/Note.md" href="Folder/Note.md" class="internal-link">. The lazy [^>]*? ate data-, so the filter rewrote the data-href attribute to /404. The pre-existing dataview-js-links transform — which resolves these anchors from data-href — then read the clobbered value and marked every dataview link unresolved.
  2. resolveVaultPath treated vault-root targets as note-relative. Dataview (and Obsidian's "absolute path in vault" link setting) emit targets like Folder/Note.md with no .//../ prefix. For notes in subfolders these were joined with the note's directory, the lookup missed, and the href became /404.

Fix

  • The anchor regex now requires href to be a standalone attribute ((?:[^>]*?\s)?href="), so data-href is never rewritten.
  • Link targets now produce ordered candidate interpretations: note-relative first (preserving fix: resolve markdown-style relative .md links to permalinks #398's behavior for genuinely relative links), vault-root as fallback. resolveMdLinks picks the first candidate that resolves to a real note; only when none do does it keep the /404 + is-unresolved handling. Graph extraction emits all candidates; ones matching no note are dropped as before.

Verification

  • TDD: 6 new tests written failing first, whole suite green (309 tests).
  • End-to-end build of the test garden with notes in subfolders covering dataviewjs-style anchors, vault-absolute .md links, and relative .md links — all resolve to real permalinks; genuinely dead links still get /404 with is-unresolved.

🤖 Generated with Claude Code

The resolveMdLinks filter added in 1.83.0 (#398) sent every
dataview-generated link to /404, two defects compounding:

- convertMdHrefs' anchor regex matched the tail of data-href=", so
  dataviewjs anchors (<a data-href="Folder/Note.md" href=...>) had
  their data-href clobbered to /404 before the dataview-js-links
  transform could resolve the anchor from it. The regex now requires
  href to be a standalone attribute.
- resolveVaultPath treated vault-root targets (Folder/Note.md, as
  dataview and Obsidian's "absolute path in vault" setting emit) as
  note-relative, so links from nested notes resolved to paths that
  don't exist. Targets now yield ordered candidate interpretations,
  note-relative first, vault-root as fallback, and the filter picks
  the first that resolves to a real note. Dead links keep the /404 +
  is-unresolved handling.

Verified with unit tests (TDD, 6 new failing tests before the fix)
and an end-to-end build of the test garden covering dataviewjs
anchors, vault-absolute and relative .md links.

Fixes #399

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@oleeskild
oleeskild merged commit 4f3ab66 into main Aug 11, 2026
1 check passed
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.

Commit 4c0c195386484f2f785e571b9e0f1e7e1eaf8a90 (update to 1.83.0) breaks dataview queries

1 participant