fish2018/pansou · error

缓存文件中缺少键

Error message

缓存文件中缺少键: %s

What it means

Cache-integrity error in PanyqPlugin.loadActionIDsFromFile (plugin/panyq/panyq.go:1381): the config file loaded and parsed, but one of the required ActionIDKeys is absent from the map, so the cached action IDs are incomplete and must be re-discovered.

Solutions

  1. 删除损坏缓存文件并重新发现 action ID
  2. 加载失败时自动回退到 discoverActionIDs 流程
  3. 写文件时做原子写入避免损坏
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at plugin/panyq/panyq.go:1381 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/d59deec63b69bf1d. Report an issue: GitHub.

Appendix: source

Thrown at plugin/panyq/panyq.go:1381

// loadActionIDsFromFile 从文件加载Action IDs
func (p *PanyqPlugin) loadActionIDsFromFile() (map[string]string, error) {
	configPath := filepath.Join(".", ConfigFileName)
	
	data, err := os.ReadFile(configPath)
	if err != nil {
		return nil, err
	}
	
	var ids map[string]string
	if err := json.Unmarshal(data, &ids); err != nil {
		return nil, err
	}
	
	// 验证所有必需的键是否存在
	for _, key := range ActionIDKeys {
		if _, ok := ids[key]; !ok {
			return nil, fmt.Errorf("缓存文件中缺少键: %s", key)
		}
	}
	
	return ids, nil
}

// saveActionIDsToFile 保存Action IDs到文件
func (p *PanyqPlugin) saveActionIDsToFile(ids map[string]string) error {
	data, err := json.Marshal(ids)
	if err != nil {
		return err
	}
	
	configPath := filepath.Join(".", ConfigFileName)
	return os.WriteFile(configPath, data, 0644)
}

View on GitHub (pinned to beaa561337)