apache/answer · error
update plugin status failed: %w
Error message
update plugin status failed: %w
What it means
deactivatePlugin wraps a failure from xorm's Update that persists the modified plugin status JSON back to the config row (Cols("value")). It is thrown when the UPDATE statement fails after the row was successfully read.
Source
Thrown at internal/cli/config.go:123
pluginStatusMapping := make(map[string]bool)
_ = json.Unmarshal([]byte(item.Value), &pluginStatusMapping)
status, ok := pluginStatusMapping[pluginSlugName]
if !ok {
fmt.Printf("plugin %s not exist\n", pluginSlugName)
return nil
}
if !status {
fmt.Printf("plugin %s already deactivated\n", pluginSlugName)
return nil
}
pluginStatusMapping[pluginSlugName] = false
dataByte, _ := json.Marshal(pluginStatusMapping)
item.Value = string(dataByte)
_, err = x.ID(item.ID).Cols("value").Update(item)
if err != nil {
return fmt.Errorf("update plugin status failed: %w", err)
}
return nil
}
View on GitHub (pinned to 3b9f137061)
Solutions
- Ensure item.ID is valid before updating (row actually fetched with exist==true and non-zero ID).
- Check DB connectivity and retry the operation.
- Inspect the wrapped driver error for lock/constraint causes.
Defensive patterns
Strategy: retry
Validate before calling
row := &entity.Config{Key: constant.PluginStatus}
if exist, err := x.Get(row); err != nil || !exist || row.ID == 0 { return err } Try / catch
if err := cli.SetDefaultConfig(...); err != nil {
if strings.Contains(err.Error(), "update plugin status failed") {
// inspect err for lock/constraint causes, retry with backoff
}
} Prevention
- Avoid concurrent CLI mutations of plugin status
- Ensure rows are fetched with valid primary keys
- Use short transactions to reduce lock contention
When it happens
Trigger: x.ID(item.ID).Cols("value").Update(item) fails — e.g. item.ID is zero/invalid (row had no ID), the row was deleted concurrently, or a DB constraint/lock prevents the update.
Common situations: Concurrent CLI runs modifying plugin status, DB connection dropped between Get and Update, or config row lacking a valid primary key ID.
Related errors
- get config failed: %w
- update site info failed: %w
- %s failed: %s
- sync version failed: %v
- get config failed: %w
AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05).
Data as JSON: /api/errors/4b14cd5039a3d110.
Report an issue: GitHub.