{"record":{"id":"4dbf12fadc1c09fe","repo":"wtfutil/wtf","slug":"failed-to-marshal-request-v","errorCode":null,"errorMessage":"failed to marshal request: %v","messagePattern":"failed to marshal request: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"modules/jira/client.go","lineNumber":124,"sourceCode":"// ConvertJQLWithUsername converts a JQL query containing username to account ID\nfunc (widget *Widget) ConvertJQLWithUsername(username string) (string, error) {\n\t// Check cache first\n\tif accountID, found := userIDCache.Get(username); found {\n\t\treturn fmt.Sprintf(\"assignee = \\\"%s\\\"\", accountID), nil\n\t}\n\n\t// Create a JQL query with the username that needs conversion\n\toriginalJQL := fmt.Sprintf(\"assignee = \\\"%s\\\"\", username)\n\n\t// Prepare the request body\n\trequestBody := JQLConversionRequest{\n\t\tQueryStrings: []string{originalJQL},\n\t}\n\n\t// Convert to JSON\n\tjsonData, err := json.Marshal(requestBody)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"failed to marshal request: %v\", err)\n\t}\n\n\t// Make the POST request to the JQL conversion API\n\tresp, err := widget.jiraPostRequest(\"/rest/api/3/jql/pdcleaner\", jsonData)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tvar conversionResult JQLConversionResponse\n\terr = utils.ParseJSON(&conversionResult, bytes.NewReader(resp))\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\tif len(conversionResult.QueryStrings) == 0 {\n\t\treturn \"\", fmt.Errorf(\"no conversion result for username: %s\", username)\n\t}\n","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/jira/client.go#L106-L142","documentation":"ConvertJQLWithUsername fails when json.Marshal cannot serialize the JQL conversion request body before POSTing it to Jira's /rest/api/3/jql/pdcleaner. In practice this is near-impossible with the simple request struct, so the error almost always indicates a programming/structural fault rather than an environment problem.","triggerScenarios":"Calling ConvertJQLWithUsername when the internal requestBody value cannot be marshaled - essentially only if the struct or QueryStrings field is replaced with an unmarshalable type (chan, func, invalid map key) in a code change.","commonSituations":"Custom forks or modifications to the Jira client that add unserializable fields to the request struct; not something users hit through configuration.","solutions":["Inspect the error detail (%v) to identify the unmarshalable value","Review recent changes to the request struct in client.go for unsupported field types","Restore the original requestBody definition or make added fields JSON-serializable"],"exampleFix":"// before\nrequestBody := struct {\n    Callback chan int `json:\"callback\"` // unmarshalable\n    QueryStrings []string\n}{...}\n// after\nrequestBody := struct {\n    QueryStrings []string `json:\"queryStrings\"`\n}{QueryStrings: []string{originalJQL}}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"query, err := widget.ConvertJQLWithUsername(username)\nif err != nil {\n    if strings.HasPrefix(err.Error(), \"failed to marshal request\") {\n        log.Printf(\"client bug: request struct not serializable: %v\", err)\n    }\n    return err\n}","preventionTips":["Keep the request struct limited to JSON-serializable types (strings, slices)","Add json.Marshal to a unit test of the request body","Tag struct fields explicitly with json tags","Avoid embedding channels/funcs/cyclic pointers in request types"],"tags":["json","serialization","go","jira"],"backgroundTag":"json-marshal-failed","analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}