IceWhaleTech/CasaOS · error

get config failed

Error message

get config failed

What it means

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.

Source

Thrown at pkg/utils/httper/drive.go:154

	}).Post("/config/get")
	if err != nil {
		return nil, err
	}
	if res.StatusCode() != 200 {
		return nil, fmt.Errorf("create config failed")
	}
	var result map[string]string
	json.Unmarshal(res.Body(), &result)
	return result, nil
}
func GetAllConfigName() (RemotesResult, error) {
	var result RemotesResult
	res, err := NewRestyClient().R().SetFormData(map[string]string{}).Post("/config/listremotes")
	if err != nil {
		return result, err
	}
	if res.StatusCode() != 200 {
		return result, fmt.Errorf("get config failed")
	}

	json.Unmarshal(res.Body(), &result)
	return result, nil
}
func DeleteConfigByName(name string) error {
	res, err := NewRestyClient().R().SetFormData(map[string]string{
		"name": name,
	}).Post("/config/delete")
	if err != nil {
		return err
	}
	if res.StatusCode() != 200 {
		return fmt.Errorf("delete config failed")
	}
	return nil
}

View on GitHub (pinned to 0d3b2f444e)

Solutions

  1. Verify the rclone service process is up and its rc address/port matches the one NewRestyClient() targets (curl the /core/version rc endpoint directly).
  2. If the rc endpoint requires auth, add the --rc-user/--rc-pass equivalent header in NewRestyClient().
  3. Restart the drive/rclone service and retry the listing once.
  4. Check the json.Unmarshal error after unmarshalling so corrupt responses surface instead of returning an empty RemotesResult.

Example fix

// before
if res.StatusCode() != 200 {
    return result, fmt.Errorf("get config failed")
}
json.Unmarshal(res.Body(), &result)
return result, nil

// after
if res.StatusCode() != 200 {
    return result, fmt.Errorf("get config failed: status=%d body=%s", res.StatusCode(), res.Body())
}
if err := json.Unmarshal(res.Body(), &result); err != nil {
    return result, fmt.Errorf("decode listremotes response: %w", err)
}
return result, nil
Defensive patterns

Strategy: retry

Validate before calling

// before GetAllConfigName(): cheap liveness probe of the rclone rc endpoint
res, err := httper.NewRestyClient().R().Post("/core/version")
if err != nil || res.StatusCode() != 200 {
    return fmt.Errorf("rclone rc service unhealthy")
}

Try / catch

var names httper.RemotesResult
var err error
for attempt := 0; attempt < 2; attempt++ {
    names, err = httper.GetAllConfigName()
    if err == nil {
        break
    }
    // only transport/5xx failures are worth one retry; give the service a moment
    time.Sleep(500 * time.Millisecond)
}
if err != nil {
    return nil, fmt.Errorf("list rclone remotes after retry: %w", err)
}

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of IceWhaleTech/CasaOS@0d3b2f444e (2026-08-15). Data as JSON: /api/errors/f0ed165c1be87527. Report an issue: GitHub.