{"record":{"id":"b4d9acbf3a8d5fa5","repo":"Tencent/WeKnora","slug":"unable-to-parse-date-s","errorCode":null,"errorMessage":"unable to parse date: %s","messagePattern":"unable to parse date: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/infrastructure/web_search/baidu.go","lineNumber":175,"sourceCode":"\t\tif includeDate && ref.Date != \"\" {\n\t\t\tif t, err := parseBaiduDate(ref.Date); err == nil {\n\t\t\t\tresult.PublishedAt = &t\n\t\t\t}\n\t\t}\n\n\t\tresults = append(results, result)\n\t}\n\treturn results, nil\n}\n\nvar baiduDateRe = regexp.MustCompile(`^(\\d{4})-(\\d{1,2})-(\\d{1,2})(?:\\s+(\\d{1,2}):(\\d{2})(?::(\\d{2}))?)?`)\n\n// parseBaiduDate extracts date components via regex, handling variable formats\n// like \"2025-4-24\", \"2025-04-27 18:02:00\", \"2025-05-20 11:58\" uniformly.\nfunc parseBaiduDate(dateStr string) (time.Time, error) {\n\tm := baiduDateRe.FindStringSubmatch(dateStr)\n\tif m == nil {\n\t\treturn time.Time{}, fmt.Errorf(\"unable to parse date: %s\", dateStr)\n\t}\n\t// Pad to \"YYYY-MM-DD HH:MM:SS\" and parse once\n\tnormalized := fmt.Sprintf(\"%s-%02s-%02s %02s:%02s:%02s\",\n\t\tm[1], m[2], m[3],\n\t\tdefaultStr(m[4], \"00\"), defaultStr(m[5], \"00\"), defaultStr(m[6], \"00\"))\n\treturn time.Parse(\"2006-01-02 15:04:05\", normalized)\n}\n\nfunc defaultStr(s, fallback string) string {\n\tif s == \"\" {\n\t\treturn fallback\n\t}\n\treturn s\n}\n\n// Baidu documents the query length limit as 72 chars, counting CJK/full-width\n// runes as 2. Use a conservative width model so mixed-language input stays\n// under the API limit.","sourceCodeStart":157,"sourceCodeEnd":193,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/infrastructure/web_search/baidu.go#L157-L193","documentation":"Returned by parseBaiduDate when the date string from a Baidu result matches none of the expected formats (baiduDateRe finds no components). The error is logged/tolerated by doSearch — the result is kept without a PublishedAt timestamp.","triggerScenarios":"Thrown at internal/infrastructure/web_search/baidu.go:175 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the unexpected date format and extend baiduDateRe if it is a new valid variant","Accept results without PublishedAt — the search pipeline already handles a missing date"],"exampleFix":null,"handlingStrategy":"fallback","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"}