siyuan-note/siyuan · error

list attribute views failed

Error message

list attribute views failed: %w

What it means

workspaceAttributeViewCustomColorUsage walks storage/av to map which attribute views use which custom color indexes. If listing that directory fails (appendPaths error) and strict mode is on, the scan aborts with this wrapped error, causing the palette update to fail. In non-strict mode it only logs a warning.

Solutions

  1. Restore read access to <workspace>/data/storage/av and its .av files (chmod/chown).
  2. Check the wrapped cause: if a specific .av file is unreadable, repair or restore it from backup/sync.
  3. If the directory is genuinely gone, let the kernel recreate it by opening the workspace and creating an attribute view, then retry.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check: storage/av must be listable
// if _, err := os.ReadDir(filepath.Join(dataDir, "storage", "av")); err != nil { repair access first }

Try / catch

if err != nil && strings.Contains(err.Error(), "list attribute views failed") {
    // fix permissions or restore the .av file named in the wrapped cause, then retry
}

Prevention

When it happens

Trigger: setInlineStylesData invoking the usage scan when storage/av cannot be listed — missing/unreadable directory, permission denied, or an error while walking individual .av files in strict mode.

Common situations: Corrupted or partially deleted storage/av directory; permission changes on the workspace folder; an unreadable .av file (disk error) during the walk with strict=true.

Understand the failure class

Background: "failed to read file", EACCES, ENOENT and "could not read <path>" errors: when a program can't read a file from disk — this error's family across 49 libraries.

Related errors


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

Appendix: 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 9f775e8a12)