{"record":{"id":"f0ed165c1be87527","repo":"IceWhaleTech/CasaOS","slug":"get-config-failed","errorCode":null,"errorMessage":"get config failed","messagePattern":"get config failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/utils/httper/drive.go","lineNumber":154,"sourceCode":"\t}).Post(\"/config/get\")\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif res.StatusCode() != 200 {\n\t\treturn nil, fmt.Errorf(\"create config failed\")\n\t}\n\tvar result map[string]string\n\tjson.Unmarshal(res.Body(), &result)\n\treturn result, nil\n}\nfunc GetAllConfigName() (RemotesResult, error) {\n\tvar result RemotesResult\n\tres, err := NewRestyClient().R().SetFormData(map[string]string{}).Post(\"/config/listremotes\")\n\tif err != nil {\n\t\treturn result, err\n\t}\n\tif res.StatusCode() != 200 {\n\t\treturn result, fmt.Errorf(\"get config failed\")\n\t}\n\n\tjson.Unmarshal(res.Body(), &result)\n\treturn result, nil\n}\nfunc DeleteConfigByName(name string) error {\n\tres, err := NewRestyClient().R().SetFormData(map[string]string{\n\t\t\"name\": name,\n\t}).Post(\"/config/delete\")\n\tif err != nil {\n\t\treturn err\n\t}\n\tif res.StatusCode() != 200 {\n\t\treturn fmt.Errorf(\"delete config failed\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/IceWhaleTech/CasaOS/blob/0d3b2f444ec0193193cf03eef6d43c6e35b0183e/pkg/utils/httper/drive.go#L136-L172","documentation":"Returned by GetAllConfigName() in pkg/utils/httper/drive.go when POST /config/listremotes responds non-200. This endpoint takes no parameters and simply lists rclone remote names, so a failure almost always means the rclone REST service itself is unreachable at the transport level, returned a 5xx, or requires an auth header that NewRestyClient() did not send. Note json.Unmarshal of the body is also unchecked, so a 200 with malformed JSON would silently yield an empty list instead of an error.","triggerScenarios":"(1) rclone/drive service down or crashed, (2) port mismatch between what CasaOS configured and what rclone listens on, (3) reverse proxy in front of rclone returning 502/401, (4) rclone compiled without the rc serve module so /config/listremotes 404s.","commonSituations":"Drive list page empty with backend errors after an update changed the rclone service port; CasaOS in Docker where the rclone sidecar is not linked; auth token rotation on the rc endpoint; OOM-killed rclone process on low-RAM devices.","solutions":["Verify the rclone service process is up and its rc address/port matches the one NewRestyClient() targets (curl the /core/version rc endpoint directly).","If the rc endpoint requires auth, add the --rc-user/--rc-pass equivalent header in NewRestyClient().","Restart the drive/rclone service and retry the listing once.","Check the json.Unmarshal error after unmarshalling so corrupt responses surface instead of returning an empty RemotesResult."],"exampleFix":"// before\nif res.StatusCode() != 200 {\n    return result, fmt.Errorf(\"get config failed\")\n}\njson.Unmarshal(res.Body(), &result)\nreturn result, nil\n\n// after\nif res.StatusCode() != 200 {\n    return result, fmt.Errorf(\"get config failed: status=%d body=%s\", res.StatusCode(), res.Body())\n}\nif err := json.Unmarshal(res.Body(), &result); err != nil {\n    return result, fmt.Errorf(\"decode listremotes response: %w\", err)\n}\nreturn result, nil","handlingStrategy":"retry","validationCode":"// before GetAllConfigName(): cheap liveness probe of the rclone rc endpoint\nres, err := httper.NewRestyClient().R().Post(\"/core/version\")\nif err != nil || res.StatusCode() != 200 {\n    return fmt.Errorf(\"rclone rc service unhealthy\")\n}","typeGuard":null,"tryCatchPattern":"var names httper.RemotesResult\nvar err error\nfor attempt := 0; attempt < 2; attempt++ {\n    names, err = httper.GetAllConfigName()\n    if err == nil {\n        break\n    }\n    // only transport/5xx failures are worth one retry; give the service a moment\n    time.Sleep(500 * time.Millisecond)\n}\nif err != nil {\n    return nil, fmt.Errorf(\"list rclone remotes after retry: %w\", err)\n}","preventionTips":["Add a health check for the drive/rclone service to CasaOS service monitoring.","Pin and verify the rc port in one place; fail loudly at startup if it does not answer.","Check json.Unmarshal errors so empty results are never mistaken for 'no remotes'.","Alert on repeated 5xx from /config/* — that indicates the rclone process is failing."],"tags":["rclone","config","service-health","http-client","casaos"],"backgroundTag":null,"analyzedSha":"0d3b2f444ec0193193cf03eef6d43c6e35b0183e","analyzedAt":"2026-08-15T13:27:57.821Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}