{"record":{"id":"b369b5560ac79103","repo":"fish2018/pansou","slug":"s-w-b369b5","errorCode":null,"errorMessage":"[%s] 序列化请求体失败: %w","messagePattern":"\\[(.+?)\\] 序列化请求体失败: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"plugin/meitizy/meitizy.go","lineNumber":146,"sourceCode":"\n// SearchWithResult 执行搜索并返回包含IsFinal标记的结果\nfunc (p *MeitizyPlugin) SearchWithResult(keyword string, ext map[string]interface{}) (model.PluginSearchResult, error) {\n\treturn p.AsyncSearchWithResult(keyword, p.searchImpl, p.MainCacheKey, ext)\n}\n\n// searchImpl 搜索实现\nfunc (p *MeitizyPlugin) searchImpl(client *http.Client, keyword string, ext map[string]interface{}) ([]model.SearchResult, error) {\n\t// 构建请求体\n\treqBody := searchRequest{\n\t\tTitle: keyword,\n\t\tPage:  1,\n\t\tSize:  MaxPageSize,\n\t}\n\n\t// 序列化请求体\n\tjsonData, err := json.Marshal(reqBody)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 序列化请求体失败: %w\", p.Name(), err)\n\t}\n\n\t// 构建请求URL\n\tapiURL := BaseURL + SearchPath\n\n\t// 创建带超时的上下文\n\tctx, cancel := context.WithTimeout(context.Background(), RequestTimeout)\n\tdefer cancel()\n\n\t// 创建POST请求\n\treq, err := http.NewRequestWithContext(ctx, \"POST\", apiURL, bytes.NewBuffer(jsonData))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"[%s] 创建请求失败: %w\", p.Name(), err)\n\t}\n\n\t// 设置请求头\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\treq.Header.Set(\"User-Agent\", UserAgent)","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/fish2018/pansou/blob/beaa56133755a548ebc51b090b3816e2ae044aa6/plugin/meitizy/meitizy.go#L128-L164","documentation":"meitizy's searchImpl marshals the searchRequest struct (Title/Page/Size) to JSON with json.Marshal before sending the POST. This error wraps that marshal failure. All fields of searchRequest are plain JSON-serializable types, so this is essentially unreachable in normal operation and indicates an unexpected struct change (e.g. a field of an unserializable type like chan or func added).","triggerScenarios":"json.Marshal fails on the searchRequest struct — only possible if the struct gains a field with a type json cannot encode (channel, func, cyclic pointer) or a MarshalJSON method that returns an error.","commonSituations":"A developer extends searchRequest with an unsupported field type or a custom MarshalJSON that errors; keyword content never affects this because strings always serialize.","solutions":["Inspect the wrapped %w error and recent changes to the searchRequest struct","Remove or fix the unserializable field, or add a json:\"-\" tag to exclude it","Add a unit test marshaling searchRequest to catch regressions"],"exampleFix":"// before\nType: someChan // json.Marshal fails on chan\n// after\n//  exclude non-serializable fields from the wire format\nsomeChan any `json:\"-\"`","handlingStrategy":"type-guard","validationCode":"if _, err := json.Marshal(searchRequest{Title: keyword, Page: 1, Size: MaxPageSize}); err != nil {\n    log.Printf(\"searchRequest not serializable: %v\", err)\n}","typeGuard":null,"tryCatchPattern":"if err != nil {\n    log.Printf(\"marshal failed: %v\", err)\n    return nil, err // programmer error: fail fast, do not retry\n}","preventionTips":["Keep searchRequest limited to JSON-native field types (string, int)","Never add chan/func/cyclic pointer fields without a json:\"-\" tag","Add a CI test that marshals every request struct"],"tags":["json","serialization","go"],"backgroundTag":"json-marshal-failed","analyzedSha":"beaa56133755a548ebc51b090b3816e2ae044aa6","analyzedAt":"2026-09-07T00:31:18.025Z","contentChangedAt":"2026-09-07T00:31:18.025Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}