{"record":{"id":"134ee1157c02f638","repo":"chenhg5/cc-connect","slug":"marshal-request-w-134ee1","errorCode":null,"errorMessage":"marshal request: %w","messagePattern":"marshal request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"platform/dingtalk/dingtalk.go","lineNumber":686,"sourceCode":"\t\tmimeType = \"audio/amr\" // Default to AMR if not specified\n\t}\n\n\treturn data, mimeType, nil\n}\n\nfunc (p *Platform) getDownloadURL(downloadCode string) (string, error) {\n\ttoken, err := p.getAccessToken()\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"get access token: %w\", err)\n\t}\n\n\treqBody := map[string]string{\n\t\t\"downloadCode\": downloadCode,\n\t\t\"robotCode\":    p.robotCode,\n\t}\n\tbodyBytes, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"marshal request: %w\", err)\n\t}\n\n\tctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\n\tdefer cancel()\n\treq, err := http.NewRequestWithContext(ctx, http.MethodPost,\n\t\t\"https://api.dingtalk.com/v1.0/robot/messageFiles/download\",\n\t\tbytes.NewReader(bodyBytes))\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"create request: %w\", err)\n\t}\n\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"x-acs-dingtalk-access-token\", token)\n\n\tresp, err := p.httpClient.Do(req)\n\tif err != nil {\n\t\treturn \"\", fmt.Errorf(\"do request: %w\", err)\n\t}","sourceCodeStart":668,"sourceCodeEnd":704,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/platform/dingtalk/dingtalk.go#L668-L704","documentation":"getDownloadURL wraps a json.Marshal failure of the request body {downloadCode, robotCode}. With a plain map[string]string this is nearly impossible at runtime (map[string]string always marshals), so encountering it indicates an unexpected marshalling defect; it exists to preserve the error chain.","triggerScenarios":"json.Marshal(reqBody) returned an error in getDownloadURL before issuing the HTTP request.","commonSituations":"In practice: should never occur with the current request shape. If seen, it points to a modified/broken build or an unexpected runtime fault rather than user configuration.","solutions":["Confirm you are running an unmodified build of the platform package.","If reproducible, report a bug with the full wrapped error chain; the request body is a fixed map[string]string and cannot normally fail.","No user-side configuration change can prevent this; treat as an internal invariant violation."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"marshal request\") {\n    // Should be unreachable; treat as a bug\n    log.Error(\"dingtalk: internal marshal failure\", \"err\", err)\n    return fmt.Errorf(\"internal error, please report: %w\", err)\n}","preventionTips":["Keep the request body a marshalable type (map[string]string or a struct of strings)","Never inject unmarshalable values (channels, funcs) into request maps","Report occurrences upstream as internal invariant violations"],"tags":["dingtalk","json","serialization","api"],"backgroundTag":"json-marshal-failed","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}