{"record":{"id":"752e8bbcfab6207c","repo":"AlistGo/alist","slug":"unsupported-method-s","errorCode":null,"errorMessage":"unsupported method: %s","messagePattern":"unsupported method: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/pcloud/util.go","lineNumber":146,"sourceCode":"\n\tif callback != nil {\n\t\tcallback(req)\n\t}\n\n\tif resp != nil {\n\t\treq.SetResult(resp)\n\t}\n\n\tvar res *resty.Response\n\tvar err error\n\n\tswitch method {\n\tcase http.MethodGet:\n\t\tres, err = req.Get(d.getAPIURL() + endpoint)\n\tcase http.MethodPost:\n\t\tres, err = req.Post(d.getAPIURL() + endpoint)\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unsupported method: %s\", method)\n\t}\n\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\t// Check for API errors with pCloud-specific logic\n\tif res.StatusCode() != 200 {\n\t\tvar errResp ErrorResult\n\t\tif err := utils.Json.Unmarshal(res.Body(), &errResp); err == nil {\n\t\t\t// Check if this error should trigger a retry\n\t\t\tif d.shouldRetry(res.StatusCode(), &errResp) {\n\t\t\t\treturn nil, fmt.Errorf(\"pCloud API error (retryable): %s (result: %d)\", errResp.Error, errResp.Result)\n\t\t\t}\n\t\t\treturn nil, fmt.Errorf(\"pCloud API error: %s (result: %d)\", errResp.Error, errResp.Result)\n\t\t}\n\t\treturn nil, fmt.Errorf(\"HTTP error: %d\", res.StatusCode())\n\t}","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/pcloud/util.go#L128-L164","documentation":"Thrown by PCloud.requestWithRetry when the HTTP method passed to the helper is neither GET nor POST. The pCloud client centralizes all calls through this switch, so any endpoint implementation that tries to use PUT, DELETE, or PATCH hits the default branch immediately, before any network traffic occurs. It is a pure programmer/caller error, not an API or network condition.","triggerScenarios":"Calling d.requestWithRetry(endpoint, http.MethodPut/Delete/Patch, ...) from a pCloud driver method. Every current in-tree call site uses only GET or POST, so this fires only from new/modified driver code or a refactor that changed the method constant.","commonSituations":"Adding a new pCloud operation (e.g. a rename via PATCH) without extending the switch; copy-pasting a call from another driver that supports more verbs; refactoring util.go and accidentally changing the method argument.","solutions":["Change the caller to use http.MethodGet or http.MethodPost, which are the only verbs the switch handles","If the new operation genuinely needs another verb, add a case for it in requestWithRetry's switch (e.g. case http.MethodDelete: res, err = req.Delete(...)) before the default branch","Audit call sites with grep for 'requestWithRetry(' to confirm which method constant is being passed"],"exampleFix":"// before\n_, err := d.requestWithRetry(\"/rename\", http.MethodPatch, func(req *resty.Request) {\n    req.SetQueryParam(\"fileid\", id)\n}, &resp)\n\n// after\n_, err := d.requestWithRetry(\"/rename\", http.MethodPut, func(req *resty.Request) {\n    req.SetQueryParam(\"fileid\", id)\n}, &resp)","handlingStrategy":"validation","validationCode":"func validMethod(method string) bool {\n    return method == http.MethodGet || method == http.MethodPost\n}\n\n// before calling:\nif !validMethod(method) {\n    return nil, fmt.Errorf(\"pCloud driver supports only GET/POST, got %s\", method)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep an allowlist constant PCloudMethods = []string{http.MethodGet, http.MethodPost} and validate new call sites against it in review","Add a unit test enumerating unsupported verbs asserting the exact error message","Prefer extending the switch when adding verbs rather than working around the guard"],"tags":["pcloud","http","programming-error","driver"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}