{"record":{"id":"c1fd18d15284ff98","repo":"flipped-aurora/gin-vue-admin","slug":"request-failed-s-s","errorCode":null,"errorMessage":"request failed: %s %s","messagePattern":"request failed: (.+?) (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/cmd/gva/runner.go","lineNumber":53,"sourceCode":"\t\t\theader = \"x-token\"\n\t\t}\n\t\treq.Header.Set(header, cfg.Token)\n\t}\n\tif len(payload) > 0 {\n\t\tcontentType := def.ContentType\n\t\tif contentType == \"\" {\n\t\t\tcontentType = \"application/json\"\n\t\t}\n\t\treq.Header.Set(\"Content-Type\", contentType)\n\t}\n\tresp, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer resp.Body.Close()\n\tif resp.StatusCode >= http.StatusBadRequest {\n\t\tbody, _ := io.ReadAll(resp.Body)\n\t\treturn fmt.Errorf(\"request failed: %s %s\", resp.Status, strings.TrimSpace(string(body)))\n\t}\n\t_, err = io.Copy(cmd.OutOrStdout(), resp.Body)\n\treturn err\n}\n\nfunc buildRequestPayload(def ManifestCommand, cmd *cobra.Command) ([]byte, string, error) {\n\tpath := def.Path\n\tqueryParts := make([]string, 0)\n\tbody := make(map[string]any)\n\tfor _, param := range def.Parameters {\n\t\tvalue, err := cmd.Flags().GetString(param.Flag)\n\t\tif err != nil {\n\t\t\treturn nil, \"\", err\n\t\t}\n\t\tif strings.TrimSpace(value) == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tswitch param.Location {","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/flipped-aurora/gin-vue-admin/blob/3136500ef380842b0eb6c4daa87c3f8a47fcf9e0/server/cmd/gva/runner.go#L35-L71","documentation":"The gva CLI runner sends a manifest-defined command as an HTTP request to the gva server. Any response with status >= 400 is converted into this error containing the HTTP status line plus the response body, so the server-side error message surfaces directly in the CLI.","triggerScenarios":"The server responds 4xx/5xx to the CLI request: invalid/expired JWT (401), Casbin denial (403), bad payload (400/422), or server error (500).","commonSituations":"Token in local CLI config expired; user lacks permission for the target API; request payload built by buildRequestPayload doesn't match the API contract; server is erroring.","solutions":["Read resp.Status and the body in the error message for the server's actual reason","If 401, re-login: gva login --token <new-token> to refresh the stored JWT","If 403, check the user's Casbin API permissions in the gva admin","If 400, compare the built payload against the target API's expected request struct"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := runManifestCommand(cmd, def); err != nil {\n    var reqErr *RequestFailedError\n    if errors.As(err, &reqErr) && reqErr.Status == 401 {\n        // prompt re-login: gva login --token <new>\n    }\n}","preventionTips":["Refresh the stored JWT proactively before expiry","Verify Casbin permissions for the target API before automating calls","Log the full request payload when debugging 400s"],"tags":["cli","http","api-error"],"backgroundTag":"http-4xx-client-error","analyzedSha":"3136500ef380842b0eb6c4daa87c3f8a47fcf9e0","analyzedAt":"2026-08-31T13:50:02.721Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}