AlistGo/alist · error

unsupported method: %s

Error message

unsupported method: %s

What it means

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.

Source

Thrown at drivers/pcloud/util.go:146

	if callback != nil {
		callback(req)
	}

	if resp != nil {
		req.SetResult(resp)
	}

	var res *resty.Response
	var err error

	switch method {
	case http.MethodGet:
		res, err = req.Get(d.getAPIURL() + endpoint)
	case http.MethodPost:
		res, err = req.Post(d.getAPIURL() + endpoint)
	default:
		return nil, fmt.Errorf("unsupported method: %s", method)
	}

	if err != nil {
		return nil, err
	}

	// Check for API errors with pCloud-specific logic
	if res.StatusCode() != 200 {
		var errResp ErrorResult
		if err := utils.Json.Unmarshal(res.Body(), &errResp); err == nil {
			// Check if this error should trigger a retry
			if d.shouldRetry(res.StatusCode(), &errResp) {
				return nil, fmt.Errorf("pCloud API error (retryable): %s (result: %d)", errResp.Error, errResp.Result)
			}
			return nil, fmt.Errorf("pCloud API error: %s (result: %d)", errResp.Error, errResp.Result)
		}
		return nil, fmt.Errorf("HTTP error: %d", res.StatusCode())
	}

View on GitHub (pinned to 843d9dc814)

Solutions

  1. Change the caller to use http.MethodGet or http.MethodPost, which are the only verbs the switch handles
  2. 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
  3. Audit call sites with grep for 'requestWithRetry(' to confirm which method constant is being passed

Example fix

// before
_, err := d.requestWithRetry("/rename", http.MethodPatch, func(req *resty.Request) {
    req.SetQueryParam("fileid", id)
}, &resp)

// after
_, err := d.requestWithRetry("/rename", http.MethodPut, func(req *resty.Request) {
    req.SetQueryParam("fileid", id)
}, &resp)
Defensive patterns

Strategy: validation

Validate before calling

func validMethod(method string) bool {
    return method == http.MethodGet || method == http.MethodPost
}

// before calling:
if !validMethod(method) {
    return nil, fmt.Errorf("pCloud driver supports only GET/POST, got %s", method)
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of AlistGo/alist@843d9dc814 (2026-08-15). Data as JSON: /api/errors/752e8bbcfab6207c. Report an issue: GitHub.