siyuan-note/siyuan · error

list workspace data directory failed

Error message

list workspace data directory failed: %w

What it means

The custom-color usage scan also reads the workspace data directory (util.DataDir) to enumerate per-notebook folders. If os.ReadDir fails for a reason other than not-exist and strict mode is enabled, the scan aborts with this wrapped error and the palette update fails.

Solutions

  1. Verify the workspace data directory exists and is readable by the kernel process (ls/chmod/chown).
  2. Remount or restore the workspace volume if it was unmounted or moved.
  3. If data/ was replaced by a file, restore the real directory from backup or sync and restart the kernel.
Defensive patterns

Strategy: validation

Validate before calling

info, err := os.Stat(util.DataDir)
if err != nil || !info.IsDir() {
    // workspace data directory missing or not a directory; repair before calling the API
}

Try / catch

if err != nil && strings.Contains(err.Error(), "list workspace data directory failed") {
    // verify/remount the workspace volume, then retry the palette update
}

Prevention

When it happens

Trigger: setInlineStylesData triggering workspaceAttributeViewCustomColorUsage while the workspace data directory is unreadable — permission denied, I/O error, or DataDir replaced by a non-directory in strict mode.

Common situations: Workspace data folder deleted or unmounted while the kernel runs; permission tightened on the workspace root; DataDir path pointing at a file after a bad manual move of the workspace.

Related errors


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

Appendix: source

Thrown at kernel/model/inline_style.go:416

				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)
			}
			logging.LogWarnf("list notebook attribute views [%s] for custom color refresh failed: %s",
				entry.Name(), err)
		}
	}
	sort.Strings(paths)
	for _, path := range paths {
		avID, indexes, readErr := av.ReadAttributeViewCustomColorUsageByPath(path)

View on GitHub (pinned to 9f775e8a12)