{"record":{"id":"f55179f48cc77092","repo":"v2rayA/v2rayA","slug":"setremove-unsupported-bucket-key-s-s","errorCode":null,"errorMessage":"SetRemove: unsupported bucket/key: %s/%s","messagePattern":"SetRemove: unsupported bucket/key: (.+?)/(.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"service/db/setOp.go","lineNumber":52,"sourceCode":"// SetRemove removes members from a set identified by key.\nfunc SetRemove(bucket string, key string, val interface{}) (err error) {\n\tdb := GetDB()\n\n\tswitch bucket + \"/\" + key {\n\tcase \"outbounds/names\":\n\t\tname, ok := val.(string)\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"SetRemove: outbound name must be a string\")\n\t\t}\n\t\t// Delete related connections and settings first\n\t\t_, _ = db.Exec(\"DELETE FROM outbound_connections WHERE outbound_name = ?\", name)\n\t\t_, _ = db.Exec(\"DELETE FROM outbound_settings WHERE outbound_name = ?\", name)\n\t\t// Delete the outbound name\n\t\t_, err = db.Exec(\"DELETE FROM outbound_names WHERE name = ?\", name)\n\t\treturn err\n\n\tdefault:\n\t\treturn fmt.Errorf(\"SetRemove: unsupported bucket/key: %s/%s\", bucket, key)\n\t}\n}\n\n// SetIsMember checks if a member exists in a set.\nfunc SetIsMember(bucket string, key string, member string) (bool, error) {\n\tdb := GetDB()\n\n\tswitch bucket + \"/\" + key {\n\tcase \"outbounds/names\":\n\t\tvar count int\n\t\terr := db.QueryRow(\"SELECT COUNT(*) FROM outbound_names WHERE name = ?\", member).Scan(&count)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\treturn count > 0, nil\n\n\tdefault:\n\t\treturn false, fmt.Errorf(\"SetIsMember: unsupported bucket/key: %s/%s\", bucket, key)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/v2rayA/v2rayA/blob/71e5442fc548c05680ee55eae943e6c0afe9ac51/service/db/setOp.go#L34-L70","documentation":"SetRemove is a thin wrapper over the SQLite-backed set store in v2rayA. It only supports the literal bucket/key combination \"outbounds/names\" (backed by the outbound_names table); any other bucket/key pair falls into the default switch branch and returns this error. It is an internal API-contract error: the caller passed a bucket/key the store has no implementation for.","triggerScenarios":"Calling SetRemove (directly or via RemoveOutbound) with any bucket or key other than bucket=\"outbounds\", key=\"names\", e.g. SetRemove(\"outbound\", \"names\", name), SetRemove(\"outbounds\", \"name\", name), or a misspelled bucket.","commonSituations":"New code extending the DB layer assumes other buckets are supported; refactors renamed the bucket/key strings; callers ported from the old bolt/boltdb storage which supported more buckets.","solutions":["Use bucket=\"outbounds\" and key=\"names\" exactly: SetRemove(\"outbounds\", \"names\", name)","If you need a new set bucket, add a case to the switch in service/db/setOp.go SetRemove before calling it","Check the caller (RemoveOutbound) passes constants, not hand-typed literals"],"exampleFix":"// before\ndb.SetRemove(\"outbound\", \"names\", name)\n// after\ndb.SetRemove(\"outbounds\", \"names\", name)","handlingStrategy":"validation","validationCode":"func validSetTarget(bucket, key string) bool {\n    return bucket == \"outbounds\" && key == \"names\"\n}\nif !validSetTarget(bucket, key) { return errors.New(\"unsupported bucket/key\") }","typeGuard":null,"tryCatchPattern":"if err := db.SetRemove(\"outbounds\", \"names\", name); err != nil {\n    if strings.HasPrefix(err.Error(), \"SetRemove: unsupported\") {\n        // fix call site bucket/key constants\n    }\n    return err\n}","preventionTips":["Define constants OutboundBucket=\"outbounds\", NameKey=\"names\" and use them in all set operations","Keep bucket/key strings in one place next to service/db/setOp.go","Add a unit test that exercises each Set* function with the supported pair"],"tags":["go","sqlite","storage","unsupported-operation"],"backgroundTag":"unsupported-bucket-key","analyzedSha":"71e5442fc548c05680ee55eae943e6c0afe9ac51","analyzedAt":"2026-09-05T20:04:37.459Z","contentChangedAt":"2026-09-05T20:04:37.459Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}