{"record":{"id":"268e11f8499dacb7","repo":"Tencent/WeKnora","slug":"metaso-api-returned-status-d-s","errorCode":null,"errorMessage":"Metaso API returned status %d: %s","messagePattern":"Metaso API returned status (.+?): (.+?)","errorType":"http","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/metaso.go","lineNumber":165,"sourceCode":"\t}\n\tif len(body) > maxMetasoResponseBytes {\n\t\treturn nil, fmt.Errorf(\"Metaso response exceeds %d bytes\", maxMetasoResponseBytes)\n\t}\n\treturn body, nil\n}\n\nfunc metasoHTTPError(statusCode int, body []byte) error {\n\tvar apiError struct {\n\t\tMessage string `json:\"message\"`\n\t\tError   string `json:\"error\"`\n\t}\n\tif json.Unmarshal(body, &apiError) == nil {\n\t\tdetail := strings.TrimSpace(apiError.Message)\n\t\tif detail == \"\" {\n\t\t\tdetail = strings.TrimSpace(apiError.Error)\n\t\t}\n\t\tif detail != \"\" {\n\t\t\treturn fmt.Errorf(\"Metaso API returned status %d: %s\", statusCode, detail)\n\t\t}\n\t}\n\tdetail := strings.TrimSpace(string(body))\n\tif len(detail) > 4096 {\n\t\tdetail = detail[:4096]\n\t}\n\tif detail == \"\" {\n\t\treturn fmt.Errorf(\"Metaso API returned status %d\", statusCode)\n\t}\n\treturn fmt.Errorf(\"Metaso API returned status %d: %s\", statusCode, detail)\n}\n\nfunc parseMetasoDate(value string) (time.Time, bool) {\n\tfor _, layout := range []string{time.RFC3339Nano, \"2006-01-02 15:04:05\", \"2006-01-02\"} {\n\t\tif parsed, err := time.Parse(layout, strings.TrimSpace(value)); err == nil {\n\t\t\treturn parsed, true\n\t\t}\n\t}","sourceCodeStart":147,"sourceCodeEnd":183,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/metaso.go#L147-L183","documentation":"Returned by metasoHTTPError when the Metaso API responds with a non-2xx status and its body parsed as JSON containing a message or error field — the detail is embedded after the status code. Usually an invalid API key (401), quota/credit exhaustion (402/429), or bad request (400).","triggerScenarios":"Thrown at internal/infrastructure/web_search/metaso.go:165 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the embedded detail to identify the failure","On 401 verify/rotate the Metaso API key","On 429 back off and reduce request rate","On 5xx retry with backoff"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}