sipeed/picoclaw · error

failed to parse session

Error message

failed to parse session

What it means

Sent as a 500 by handleGetSession when the session file exists but could not be read or parsed (readJSONLSession/readLegacySession returned a non-ErrNotExist error). Indicates a corrupt or unreadable session file rather than a missing one.

Solutions

  1. Inspect the session's .jsonl/.meta.json files for corruption or invalid JSON
  2. Verify file read permissions for the backend process
  3. Restore the session file from backup or remove the corrupt file
Defensive patterns

Strategy: fallback

When it happens

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

Common situations: See trigger scenarios.

Understand the failure class


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

Appendix: source

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

		sess, err = h.readJSONLSession(dir, ref.Key)
	}
	if err == nil && isEmptySession(sess) {
		err = os.ErrNotExist
	}
	if err != nil {
		if errors.Is(err, os.ErrNotExist) {
			if legacyRef, legacyErr := h.findLegacyPicoSession(dir, sessionID); legacyErr == nil {
				sess, err = h.readLegacySession(legacyRef.Path)
			}
			if err == nil && isEmptySession(sess) {
				err = os.ErrNotExist
			}
		}
		if err != nil {
			if errors.Is(err, os.ErrNotExist) {
				http.Error(w, "session not found", http.StatusNotFound)
			} else {
				http.Error(w, "failed to parse session", http.StatusInternalServerError)
			}
			return
		}
	}

	for i := range sess.Messages {
		if sess.Messages[i].CreatedAt == nil {
			sess.Messages[i].CreatedAt = &sess.Updated
		}
	}
	messages := detailSessionMessages(sess.Messages, toolFeedbackMaxArgsLength)

	w.Header().Set("Content-Type", "application/json")
	json.NewEncoder(w).Encode(map[string]any{
		"id":       sessionID,
		"messages": messages,
		"summary":  sess.Summary,
		"created":  sess.Created.Format(time.RFC3339),

View on GitHub (pinned to 49183d7e8d)