sipeed/picoclaw · error

failed to resolve sessions directory

Error message

failed to resolve sessions directory

What it means

Sent as a 500 by handleListSessions when h.sessionRuntimeSettings() fails to resolve the sessions directory (config load failure or unset workspace), so the session list cannot be enumerated. Generic guard over the directory-resolution step.

Solutions

  1. Check backend logs for the underlying sessionRuntimeSettings error
  2. Verify the workspace/session directory settings in the config point to an existing path
  3. Fix the config and reload the sessions list
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at web/backend/api/session.go:823 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of sipeed/picoclaw@49183d7e8d (2026-08-15). Data as JSON: /api/errors/a4a6d2a499ab353f. Report an issue: GitHub.

Appendix: source

Thrown at web/backend/api/session.go:823

	if len(workspace) > 0 && workspace[0] == '~' {
		home, _ := os.UserHomeDir()
		if len(workspace) > 1 && workspace[1] == '/' {
			workspace = home + workspace[1:]
		} else {
			workspace = home
		}
	}

	return filepath.Join(workspace, "sessions")
}

// handleListSessions returns a list of Pico session summaries.
//
//	GET /api/sessions
func (h *Handler) handleListSessions(w http.ResponseWriter, r *http.Request) {
	dir, toolFeedbackMaxArgsLength, err := h.sessionRuntimeSettings()
	if err != nil {
		http.Error(w, "failed to resolve sessions directory", http.StatusInternalServerError)
		return
	}

	if _, err := os.ReadDir(dir); err != nil {
		// Directory doesn't exist yet = no sessions
		w.Header().Set("Content-Type", "application/json")
		json.NewEncoder(w).Encode([]sessionListItem{})
		return
	}

	items := []sessionListItem{}
	seen := make(map[string]struct{})

	if refs, findErr := h.findPicoJSONLSessions(dir); findErr == nil {
		for _, ref := range refs {
			sess, loadErr := h.readJSONLSession(dir, ref.Key)
			if loadErr != nil || isEmptySession(sess) {
				continue

View on GitHub (pinned to 49183d7e8d)