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

  1. Ensure item.ID is valid before updating (row actually fetched with exist==true and non-zero ID).
  2. Check DB connectivity and retry the operation.
  3. 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

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


AI-assisted analysis of apache/answer@3b9f137061 (2026-09-05). Data as JSON: /api/errors/4b14cd5039a3d110. Report an issue: GitHub.