sipeed/picoclaw · error

read file

Error message

read file %s: %w

What it means

Wrapped os.ReadFile failure inside LoadDataset's per-entry loop: the directory was listed successfully, but one of the discovered .json files could not be read (deleted between listing and reading, permission denied, or an unreadable special file). %s is the full file path; a single bad file aborts the whole dataset load.

Solutions

  1. Check permissions on the reported file path
  2. Ensure no concurrent process is removing/rotating the JSON files while loading
  3. Validate the data dir contains only readable .json files
  4. Consider skipping unreadable files with a warning instead of aborting the entire load
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at cmd/membench/locomo.go:68 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/b744337ef5eec0df. Report an issue: GitHub.

Appendix: source

Thrown at cmd/membench/locomo.go:68

	}
	// Fallback to adversarial_answer (category 5)
	return qa.AdversarialAnswer
}

// LoadDataset reads all JSON files from dataDir and returns parsed samples.
func LoadDataset(dataDir string) ([]LocomoSample, error) {
	entries, err := os.ReadDir(dataDir)
	if err != nil {
		return nil, fmt.Errorf("read data dir %s: %w", dataDir, err)
	}

	var samples []LocomoSample
	for _, entry := range entries {
		if !entry.IsDir() && strings.HasSuffix(entry.Name(), ".json") {
			path := filepath.Join(dataDir, entry.Name())
			data, err := os.ReadFile(path)
			if err != nil {
				return nil, fmt.Errorf("read file %s: %w", path, err)
			}
			var batch []LocomoSample
			if err := json.Unmarshal(data, &batch); err != nil {
				return nil, fmt.Errorf("parse file %s: %w", path, err)
			}
			samples = append(samples, batch...)
		}
	}
	return samples, nil
}

// GetSessionNames returns sorted session keys (session_1, session_2, ...) from conversation.
func GetSessionNames(conv map[string]json.RawMessage) []string {
	var names []string
	for k := range conv {
		if strings.HasPrefix(k, "session_") && !strings.Contains(k, "_date_time") {
			names = append(names, k)
		}

View on GitHub (pinned to 49183d7e8d)