siyuan-note/siyuan · error

list attribute views failed: %w

Error message

list attribute views failed: %w

What it means

workspaceAttributeViewCustomColorUsage scans storage/av for .av files to build the custom-color usage map. In strict mode (required before removing colors), a failure to list the attribute-view directory aborts with this error instead of proceeding with an incomplete usage map, which would risk deleting colors still in use.

Source

Thrown at kernel/model/inline_style.go:409

			return nil
		}
		if readErr != nil {
			return readErr
		}
		for _, entry := range entries {
			if entry.IsDir() || filepath.Ext(entry.Name()) != ".json" {
				continue
			}
			avID := strings.TrimSuffix(entry.Name(), filepath.Ext(entry.Name()))
			if ast.IsNodeIDPattern(avID) {
				paths = append(paths, filepath.Join(dir, entry.Name()))
			}
		}
		return nil
	}
	if err = appendPaths(filepath.Join(util.DataDir, "storage", "av")); err != nil {
		if strict {
			return nil, fmt.Errorf("list attribute views failed: %w", err)
		}
		logging.LogWarnf("list attribute views for custom color refresh failed: %s", err)
	}
	entries, readErr := os.ReadDir(util.DataDir)
	if readErr != nil && !os.IsNotExist(readErr) {
		if strict {
			return nil, fmt.Errorf("list workspace data directory failed: %w", readErr)
		}
		logging.LogWarnf("list workspace data directory for custom color refresh failed: %s", readErr)
	}
	for _, entry := range entries {
		if !entry.IsDir() || !ast.IsNodeIDPattern(entry.Name()) {
			continue
		}
		if err = appendPaths(filepath.Join(util.DataDir, entry.Name(), "storage", "av")); err != nil {
			if strict {
				return nil, fmt.Errorf("list notebook attribute views [%s] failed: %w", entry.Name(), err)
			}

View on GitHub (pinned to 8641553a1f)

Solutions

  1. Verify storage/av exists as a directory and is readable by the kernel user; fix permissions or remove a conflicting regular file
  2. Recreate the storage/av directory (attribute views are re-indexed from .sy/.av data as needed) and retry
  3. Temporarily avoid removing custom colors until the AV listing works, so the strict check is not exercised
  4. Check the wrapped appendPaths/ReadDir error to distinguish permission vs not-a-directory problems

Example fix

# before
ls -l storage/av   # regular file
# after
rm storage/av && mkdir storage/av   # or restore the real av directory
Defensive patterns

Strategy: fallback

Validate before calling

if fi, err := os.Stat(filepath.Join(dataDir, "storage", "av")); err != nil || !fi.IsDir() {
    return fmt.Errorf("attribute view dir unusable: %v", err)
}

Try / catch

usage, err := model.WorkspaceAttributeViewCustomColorUsage(true)
if err != nil {
    log.Warnf("cannot compute AV color usage, skipping palette pruning: %v", err)
    return
}

Prevention

When it happens

Trigger: storage/av missing-but-erroring (e.g. it exists as a file, or permission denied on ReadDir); appendPaths returning an error while strict=true is passed from setInlineStylesData's removal check.

Common situations: storage/av accidentally replaced by a regular file; permission mismatch after restoring a workspace as root; workspace sync leaving the av directory in a bad state.

Related errors


AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11). Data as JSON: /api/errors/333bcb23b511a89b. Report an issue: GitHub.