You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
detectProvenance picks wrong source id when on* has multiple IsDerivedFrom #19
On `/dataset/on002718`, the provenance chip reads "NEMAR copy of ds000117" and the OpenNeuro link points at ds000117. The header correctly says "Imported from OpenNeuro ds002718" and the canonical `source_id` in the catalog is also `ds002718`.
Cause
`metadata.json` for re-released OpenNeuro datasets carries multiple `IsDerivedFrom` entries — the older OpenNeuro id (this dataset was originally released as ds000117 then re-released as ds002718) AND the canonical:
`detectProvenance` iterates with `??=` and locks the first hit (`ds000117`).
Fix
Prefer the candidate whose extracted ds id matches `id.replace(/^on/, "ds")` (the canonical on->ds swap). Fall back to the first candidate when no match. Falls back further to the swap-only path when there are no `IsDerivedFrom` entries at all (existing behavior).
Acceptance
`on002718` -> provenance chip says `ds002718`, link goes to openneuro.org/datasets/ds002718
Already fixed on main — no code change needed here.
The fix landed in PR #20 (fix(provenance): prefer canonical ds id when multiple IsDerivedFrom entries, commit a485d00), which merged into the epic branch feature/issue-1-epic-nemar-redesign on 2026-05-18. That branch's history (including this commit) is now part of main following the Phase 5 cutover. This issue stayed open only because PR #20's base at merge time wasn't the repo's default branch, so GitHub's "Closes #19" auto-close never fired.
src/lib/provenance.ts on current main already implements exactly the fix this issue asks for: it collects all DERIVED_RELATIONS candidates from related_identifiers, then picks the one whose extracted ds id matches id.replace(/^on/, "ds"), falling back to the first candidate, then to the id-swap-only path when there are no matches at all.
src/lib/provenance.test.ts on main already covers all four acceptance cases from this issue:
multiple IsDerivedFrom (on002718 -> ds002718, canonical wins over ds000117)
single matching IsDerivedFrom (on005262 -> ds005262, unchanged)
no related_identifiers (id-swap fallback, unchanged)
only a non-matching IsDerivedFrom (falls back to that entry)
Re-verified today in a clean worktree off origin/main:
bun run test — 906/906 passing, no changes needed
bun run typecheck — 0 errors
bun run lint — clean
Live check: https://data.nemar.org/on002718/metadata.json currently returns exactly the two IsDerivedFrom entries quoted in this issue (ds000117 and ds002718.v1.1.0), confirming the fixture shape is accurate and the picked id is ds002718.
Closing as already resolved. Reopen if /dataset/on002718 is still showing the wrong OpenNeuro link in production.
Activity
neuromechanist commentedon Jul 29, 2026
Already fixed on
main— no code change needed here.The fix landed in PR #20 (
fix(provenance): prefer canonical ds id when multiple IsDerivedFrom entries, commit a485d00), which merged into the epic branchfeature/issue-1-epic-nemar-redesignon 2026-05-18. That branch's history (including this commit) is now part ofmainfollowing the Phase 5 cutover. This issue stayed open only because PR #20's base at merge time wasn't the repo's default branch, so GitHub's "Closes #19" auto-close never fired.src/lib/provenance.tson currentmainalready implements exactly the fix this issue asks for: it collects allDERIVED_RELATIONScandidates fromrelated_identifiers, then picks the one whose extracted ds id matchesid.replace(/^on/, "ds"), falling back to the first candidate, then to the id-swap-only path when there are no matches at all.src/lib/provenance.test.tsonmainalready covers all four acceptance cases from this issue:IsDerivedFrom(on002718 -> ds002718, canonical wins over ds000117)IsDerivedFrom(on005262 -> ds005262, unchanged)related_identifiers(id-swap fallback, unchanged)IsDerivedFrom(falls back to that entry)Re-verified today in a clean worktree off
origin/main:bun run test— 906/906 passing, no changes neededbun run typecheck— 0 errorsbun run lint— cleanhttps://data.nemar.org/on002718/metadata.jsoncurrently returns exactly the twoIsDerivedFromentries quoted in this issue (ds000117andds002718.v1.1.0), confirming the fixture shape is accurate and the picked id isds002718.Closing as already resolved. Reopen if
/dataset/on002718is still showing the wrong OpenNeuro link in production.