{"record":{"id":"4b14cd5039a3d110","repo":"apache/answer","slug":"update-plugin-status-failed-w","errorCode":null,"errorMessage":"update plugin status failed: %w","messagePattern":"update plugin status failed: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/cli/config.go","lineNumber":123,"sourceCode":"\n\tpluginStatusMapping := make(map[string]bool)\n\t_ = json.Unmarshal([]byte(item.Value), &pluginStatusMapping)\n\tstatus, ok := pluginStatusMapping[pluginSlugName]\n\tif !ok {\n\t\tfmt.Printf(\"plugin %s not exist\\n\", pluginSlugName)\n\t\treturn nil\n\t}\n\tif !status {\n\t\tfmt.Printf(\"plugin %s already deactivated\\n\", pluginSlugName)\n\t\treturn nil\n\t}\n\n\tpluginStatusMapping[pluginSlugName] = false\n\tdataByte, _ := json.Marshal(pluginStatusMapping)\n\titem.Value = string(dataByte)\n\t_, err = x.ID(item.ID).Cols(\"value\").Update(item)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"update plugin status failed: %w\", err)\n\t}\n\treturn nil\n}\n","sourceCodeStart":105,"sourceCodeEnd":127,"githubUrl":"https://github.com/apache/answer/blob/3b9f1370612e690a0b7f230f05e688930db4c6d3/internal/cli/config.go#L105-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"Concurrent CLI runs modifying plugin status, DB connection dropped between Get and Update, or config row lacking a valid primary key ID.","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."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"row := &entity.Config{Key: constant.PluginStatus}\nif exist, err := x.Get(row); err != nil || !exist || row.ID == 0 { return err }","typeGuard":null,"tryCatchPattern":"if err := cli.SetDefaultConfig(...); err != nil {\n    if strings.Contains(err.Error(), \"update plugin status failed\") {\n        // inspect err for lock/constraint causes, retry with backoff\n    }\n}","preventionTips":["Avoid concurrent CLI mutations of plugin status","Ensure rows are fetched with valid primary keys","Use short transactions to reduce lock contention"],"tags":["database","xorm","cli"],"backgroundTag":"database-update-failed","analyzedSha":"3b9f1370612e690a0b7f230f05e688930db4c6d3","analyzedAt":"2026-09-05T18:18:39.533Z","contentChangedAt":"2026-09-05T18:18:39.533Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}