{"record":{"id":"040d54366c2e6bc5","repo":"binary-husky/gpt_academic","slug":"arxiv-category","errorCode":null,"errorMessage":"无效的arXiv类别或未找到论文: {category}","messagePattern":"无效的arXiv类别或未找到论文: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crazy_functions/review_fns/data_sources/arxiv_source.py","lineNumber":450,"sourceCode":"            # 处理类别格式\n            # 1. 转换为小写\n            # 2. 确保多个类别之间使用+连接\n            category = category.lower().replace(' ', '+')\n\n            # 构建RSS feed URL\n            feed_url = f\"https://rss.arxiv.org/rss/{category}\"\n            print(f\"正在获取RSS feed: {feed_url}\")  # 添加调试信息\n\n            feed = feedparser.parse(feed_url)\n\n            # 检查feed是否有效\n            if hasattr(feed, 'status') and feed.status != 200:\n                raise ValueError(f\"获取RSS feed失败，状态码: {feed.status}\")\n\n            if not feed.entries:\n                print(f\"警告：未在feed中找到任何条目\")  # 添加调试信息\n                print(f\"Feed标题: {feed.feed.title if hasattr(feed, 'feed') else '无标题'}\")\n                raise ValueError(f\"无效的arXiv类别或未找到论文: {category}\")\n\n            if debug:\n                # 调试模式：只获取5篇最新论文\n                search = arxiv.Search(\n                    query=f'cat:{category}',\n                    sort_by=arxiv.SortCriterion.SubmittedDate,\n                    sort_order=arxiv.SortOrder.Descending,\n                    max_results=5\n                )\n                results = list(self.client.results(search))\n                return [self._parse_paper_data(result) for result in results]\n\n            # 正常模式：获取所有新论文\n            # 从RSS条目中提取arXiv ID\n            paper_ids = []\n            for entry in feed.entries:\n                try:\n                    # RSS链接格式可能是以下几种：","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/crazy_functions/review_fns/data_sources/arxiv_source.py#L432-L468","documentation":"After fetching the category RSS successfully, the code requires feed.entries to be non-empty; an empty feed raises ValueError('无效的arXiv类别或未找到论文: {category}'). The category string was lower-cased and spaces replaced with '+' before being appended to https://rss.arxiv.org/rss/{category}, so any category token arXiv does not recognize yields a feed with no entries.","triggerScenarios":"Passing a category that is not a valid arXiv category ('machine learning', 'cs', 'AI', 'physics'), a malformed multi-category string ('cs.ai+cs.cl' — lowercase is wrong, arXiv uses cs.AI), or a valid category whose RSS momentarily returns an empty channel.","commonSituations":"Users typing free-text subjects instead of official archive.subject IDs; lowercasing cs.AI to cs.ai (the code lowercases the whole string, which breaks case-sensitive category suffixes); categories renamed/deprecated by arXiv.","solutions":["Use the official category identifier with correct case, e.g. 'cs.AI', 'cs.CL', 'math.AG', 'astro-ph.GA' — do not lowercase it before passing (the method already lowercases internally, which is itself a bug for mixed-case suffixes).","Verify the category exists on https://arxiv.org/category_taxonomy.","For multiple categories use + between full identifiers ('cs.AI+cs.LG').","If the category is valid, retry later — transient empty feeds occur during RSS regeneration."],"exampleFix":"# before\ncategory = category.lower().replace(' ', '+')\nfeed_url = f'https://rss.arxiv.org/rss/{category}'\n\n# after (preserve case of the subject suffix)\ncategory = category.strip().replace(' ', '+')\nfeed_url = f'https://rss.arxiv.org/rss/{category}'","handlingStrategy":"validation","validationCode":"import re\n\n# canonical arXiv category: archive or archive.subject (subject capitalized)\nARXIV_CAT = re.compile(r'^([a-z-]+(\\.[A-Z]{2})?)(\\+[a-z-]+(\\.[A-Z]{2})?)*$')\n\ndef valid_category(cat: str) -> bool:\n    return bool(ARXIV_CAT.match(cat.strip()))\n\nif not valid_category(category):\n    return error_response(f\"use an arXiv category like 'cs.AI', got {category!r}\")","typeGuard":null,"tryCatchPattern":"try:\n    papers = await source.fetch_by_category(category)\nexcept ValueError as e:\n    if '无效的arXiv类别' in str(e):\n        return error_response('unknown arXiv category — see https://arxiv.org/category_taxonomy')\n    raise","preventionTips":["Always pass official category IDs with correct case (cs.AI, not cs.ai).","Beware: this method lowercases the category internally — pass correct-case values and note the bug for multi-case suffixes.","Offer users a category picker sourced from the official taxonomy instead of free text."],"tags":["arxiv","validation","category","rss"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}