siyuan-note/siyuan · error

all asset mappings failed

Error message

all asset mappings failed

What it means

After running a batch plan, if zero mappings succeeded (ok == 0) and the plan was not a per-input early return, the whole operation is reported as failed with this error while the per-item reasons are carried in the result payload. It signals that none of the requested old paths could be resolved or relinked.

Solutions

  1. Inspect the per-item reasons in the returned AssetReferencesData and fix the underlying oldPath values
  2. Verify each oldPath exists under the data directory and uses the expected relative form before calling
  3. Run a dry-run first to identify which mappings fail, then resubmit corrected mappings
  4. Check you are pointing at the intended workspace (DataDir) containing those assets

Example fix

// before
result, err := model.RelinkAssets(ctx, mappings, false)
if err != nil { log.Fatal(err) } // loses per-item detail
// after
result, err := model.RelinkAssets(ctx, mappings, true) // dry run first
for _, r := range result.References { log.Printf("%s: %s", r.Path, r.Reason) }
// fix oldPath values based on reasons, then run with dryRun=false
Defensive patterns

Strategy: try-catch

Validate before calling

for _, m := range mappings {
	if _, err := os.Stat(filepath.Join(util.DataDir, m.OldPath)); err != nil {
		return fmt.Errorf("oldPath missing: %s", m.OldPath)
	}
}

Try / catch

result, err := model.RelinkAssets(ctx, mappings, false)
if err != nil && strings.Contains(fmt.Sprint(err), "all asset mappings failed") {
	for _, r := range result.References { log.Printf("item failed: %v", r) }
	// fix inputs and retry
}

Prevention

When it happens

Trigger: Calling RelinkAssets/FindAssetReferencesBatch where every OldPath fails validation or resolution (files missing, escapes, encrypted boxes, bad formats), so no route produced results.

Common situations: Paths referencing assets deleted before the call; all paths spelled with wrong prefix (missing 'assets/', absolute paths); batch of paths from a different workspace; typos in every entry copied from an outdated list.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/92a1c6e708a20022. Report an issue: GitHub.

Appendix: source

Thrown at kernel/model/asset_relink_batch.go:412

		if result.OK {
			ok++
		}
		if p.batch {
			p.result.Items = append(p.result.Items, result)
		}
	}
	if fatal != nil {
		return p.result, fatal
	}
	if !p.batch && len(p.items) == 1 {
		item := p.items[0]
		if item.reason != "" && (item.inputError || (!p.result.DryRun && !p.lookup)) {
			return p.result, errors.New(item.reason)
		}
		return p.result, nil
	}
	if ok == 0 {
		return p.result, errors.New("all asset mappings failed")
	}
	return p.result, nil
}

func (p *assetRelinkPlan) apply() (err error) {
	p.finishPreflight()
	if err = p.validateSnapshot(); err != nil {
		return err
	}
	var files []*assetRelinkFile
	for _, file := range p.files {
		if len(activeRelinkItems(file.items)) > 0 {
			files = append(files, file)
		}
	}
	var ocrSelected []int
	if p.ocrPlan != nil {
		for i, result := range p.ocrPlan.Results {

View on GitHub (pinned to 9f775e8a12)