{"record":{"id":"ce07c823037b8fd8","repo":"AlistGo/alist","slug":"darkibox-api-error-status-d-msg-s","errorCode":null,"errorMessage":"darkibox api error: status=%d msg=%s","messagePattern":"darkibox api error: status=(.+?) msg=(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"drivers/darkibox/util.go","lineNumber":42,"sourceCode":"\t\t\tcontinue\n\t\t}\n\t\tquery[k] = v\n\t}\n\n\tvar resp apiResponse\n\tr, err := base.RestyClient.R().\n\t\tSetContext(ctx).\n\t\tSetQueryParams(query).\n\t\tSetResult(&resp).\n\t\tGet(apiBase + endpoint)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif r.StatusCode() != http.StatusOK {\n\t\treturn fmt.Errorf(\"darkibox http error: %d\", r.StatusCode())\n\t}\n\tif resp.Status != 200 {\n\t\treturn fmt.Errorf(\"darkibox api error: status=%d msg=%s\", resp.Status, resp.Msg)\n\t}\n\tif out == nil || len(resp.Result) == 0 || string(resp.Result) == \"null\" {\n\t\treturn nil\n\t}\n\tif err := json.Unmarshal(resp.Result, out); err != nil {\n\t\treturn fmt.Errorf(\"decode darkibox result failed: %w\", err)\n\t}\n\treturn nil\n}\n\n// fldIDStr converts a folder ID (which may be the root \"0\") to a string suitable for API params.\nfunc fldIDStr(id string) string {\n\tif id == \"\" {\n\t\treturn \"0\"\n\t}\n\treturn id\n}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/AlistGo/alist/blob/843d9dc8149126976b2625911e45a4d3ffd6f2f5/drivers/darkibox/util.go#L24-L60","documentation":"The Darkibox API answered HTTP 200 but its envelope reported status != 200 — the provider's application-level error. The message includes the provider's numeric status and msg, which map to Darkibox's documented error codes (invalid key, file not found, folder missing, etc.).","triggerScenarios":"Operations where the provider validates business rules: listing a deleted folder, moving a nonexistent file_code, creating a folder with a duplicate/illegal name, or an API key without the required permission for that endpoint.","commonSituations":"Stale object IDs after remote changes by another client; key scoped read-only being used for writes; account quota exhausted mid-operation.","solutions":["Look up the numeric status in the Darkibox API error-code table; the msg string usually states the reason directly","Refresh the listing and retry with current IDs; if the object is gone, surface 'not found' to the user instead of retrying","For permission msgs, use a key with write scope for write operations"],"exampleFix":"// before\nif resp.Status != 200 {\n\treturn fmt.Errorf(\"darkibox api error: status=%d msg=%s\", resp.Status, resp.Msg)\n}\n// after — translate known codes to typed errors the framework understands\nif resp.Status != 200 {\n\tif resp.Msg == \"file not found\" || resp.Status == 404 {\n\t\treturn errs.ObjectNotFound\n\t}\n\treturn fmt.Errorf(\"darkibox api error: status=%d msg=%s\", resp.Status, resp.Msg)\n}","handlingStrategy":"try-catch","validationCode":"if d.APIKey == \"\" {\n\treturn errors.New(\"API key required\")\n}\nif parentRef != \"\" && !folderExists(ctx, parentRef) {\n\treturn errors.New(\"target folder missing\")\n}","typeGuard":null,"tryCatchPattern":"if m := regexp.MustCompile(`darkibox api error: status=(\\d+) msg=(.*)`).FindStringSubmatch(err.Error()); m != nil {\n\tif strings.Contains(m[2], \"not found\") { return errs.ObjectNotFound }\n\tif m[1] == \"401\" || strings.Contains(m[2], \"key\") { return reconfigureKey() }\n}","preventionTips":["Map provider status codes to typed errors at the callAPI boundary","Refresh object IDs before mutations","Use write-scoped keys for write operations"],"tags":["darkibox","api-error","provider-status","shared-helper"],"backgroundTag":null,"analyzedSha":"843d9dc8149126976b2625911e45a4d3ffd6f2f5","analyzedAt":"2026-08-15T12:14:11.722Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}