{"record":{"id":"fa7e939b17d16dc1","repo":"charmbracelet/crush","slug":"failed-to-set-permissions-skip-requests-status-co","errorCode":null,"errorMessage":"failed to set permissions skip requests: status code %d","messagePattern":"failed to set permissions skip requests: status code (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/client/proto.go","lineNumber":742,"sourceCode":"\tif rsp.StatusCode != http.StatusOK {\n\t\treturn false, fmt.Errorf(\"failed to cancel question batch: status code %d\", rsp.StatusCode)\n\t}\n\tvar resp proto.QuestionAnswerResponse\n\tif err := json.NewDecoder(rsp.Body).Decode(&resp); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to decode cancel question batch response: %w\", err)\n\t}\n\treturn resp.Resolved, nil\n}\n\n// SetPermissionsSkipRequests sets the skip-requests flag for a workspace.\nfunc (c *Client) SetPermissionsSkipRequests(ctx context.Context, id string, skip bool) error {\n\trsp, err := c.post(ctx, fmt.Sprintf(\"/workspaces/%s/permissions/skip\", id), nil, jsonBody(proto.PermissionSkipRequest{Skip: skip}), http.Header{\"Content-Type\": []string{\"application/json\"}})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to set permissions skip requests: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn fmt.Errorf(\"failed to set permissions skip requests: status code %d\", rsp.StatusCode)\n\t}\n\treturn nil\n}\n\n// GetPermissionsSkipRequests retrieves the skip-requests flag for a workspace.\nfunc (c *Client) GetPermissionsSkipRequests(ctx context.Context, id string) (bool, error) {\n\trsp, err := c.get(ctx, fmt.Sprintf(\"/workspaces/%s/permissions/skip\", id), nil, nil)\n\tif err != nil {\n\t\treturn false, fmt.Errorf(\"failed to get permissions skip requests: %w\", err)\n\t}\n\tdefer rsp.Body.Close()\n\tif rsp.StatusCode != http.StatusOK {\n\t\treturn false, fmt.Errorf(\"failed to get permissions skip requests: status code %d\", rsp.StatusCode)\n\t}\n\tvar skip proto.PermissionSkipRequest\n\tif err := json.NewDecoder(rsp.Body).Decode(&skip); err != nil {\n\t\treturn false, fmt.Errorf(\"failed to decode permissions skip requests: %w\", err)\n\t}","sourceCodeStart":724,"sourceCodeEnd":760,"githubUrl":"https://github.com/charmbracelet/crush/blob/7944b8e52225d8805e31eacbf7ef24856b0dfb7a/internal/client/proto.go#L724-L760","documentation":"This error is returned by Client.SetPermissionsSkipRequests when the HTTP POST to /workspaces/{id}/permissions/skip completes but responds with a non-200 status code. It is a deliberate guard: the server accepted the request but rejected or failed it, so the skip-requests flag was not updated. The status code is embedded in the message for diagnosis.","triggerScenarios":"Calling SetPermissionsSkipRequests against a workspace whose id does not exist (404), when the client is not authenticated or its token expired (401/403), when the JSON body fails server-side validation (400), or when the server is misbehaving (5xx). Any response other than http.StatusOK triggers it.","commonSituations":"Running a session whose daemon/token has expired; pointing the client at a server version that does not expose the permissions/skip endpoint (405/404); typo or stale workspace id after the workspace was deleted; a proxy or dev server returning 500.","solutions":["Read the status code in the message: 401/403 -> re-authenticate or re-login to refresh credentials; 404 -> verify the workspace id exists via the workspaces list API.","Confirm the server you are connected to supports the permissions/skip endpoint (server version matches your client).","Inspect server logs for a 4xx/5xx trace at /workspaces/{id}/permissions/skip and fix the request body or server-side issue.","Retry after fixing; if 5xx persists, check server health/proxy configuration."],"exampleFix":"// before: blindly calling with a stale workspace id\nerr := c.SetPermissionsSkipRequests(ctx, wsID, true)\n// after: validate id and handle status\ncode := statusFromErr(err) // e.g. parse \"status code %d\"\nif strings.Contains(err.Error(), \"status code 404\") {\n    ws, lerr := c.ListWorkspaces(ctx)\n    if lerr == nil && len(ws) > 0 {\n        err = c.SetPermissionsSkipRequests(ctx, ws[0].ID, true)\n    }\n}","handlingStrategy":"try-catch","validationCode":"// Go: check workspace exists and connectivity first\nif _, err := c.ListWorkspaces(ctx); err != nil {\n    return fmt.Errorf(\"server unreachable or auth invalid: %w\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := c.SetPermissionsSkipRequests(ctx, id, skip); err != nil {\n    var codeErr interface{ Error() string }\n    _ = codeErr\n    if strings.Contains(err.Error(), \"status code 40\") {\n        // auth/authorization or not-found: re-login or fix id\n    } else if strings.Contains(err.Error(), \"status code 5\") {\n        // server-side: retry with backoff\n    }\n    return err\n}","preventionTips":["Refresh authentication tokens before long sessions.","Validate workspace ids against the list API before mutating.","Match client and server versions so the permissions/skip endpoint exists.","Log full status codes on non-200 responses."],"tags":["http","network","api-client","permissions"],"backgroundTag":"http-non-200-response","analyzedSha":"7944b8e52225d8805e31eacbf7ef24856b0dfb7a","analyzedAt":"2026-08-29T12:48:59.079Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}