binary-husky/gpt_academic · error · Exception

分析查询失败: {str(e)}

Error message

分析查询失败: {str(e)}

What it means

A catch-all wrapper: the analyze method wraps its entire body in try/except and re-raises any inner failure as '分析查询失败: {original message}'. Every error inside analysis — missing responses (61), bad tags (62), conversion failures (60), SearchCriteria construction errors — surfaces through this single message. The inner exception text is preserved, so read the suffix to find the real cause; the original traceback is lost.

Source

Thrown at crazy_functions/paper_fns/auto_git/query_analyzer.py:304

            print(f"最低星标数: {min_stars}")
            print(f"英文GitHub参数: {english_github_query}")
            print(f"中文GitHub参数: {chinese_github_query}")
            print(f"特定仓库: {repo_id}")

            # 更新返回的 SearchCriteria,包含中英文查询
            return SearchCriteria(
                query_type=query_type,
                main_topic=main_topic,
                sub_topics=sub_topics,
                language=language,
                min_stars=min_stars,
                github_params=github_params,
                original_query=query,
                repo_id=repo_id
            )

        except Exception as e:
            raise Exception(f"分析查询失败: {str(e)}")

    def _normalize_query_type(self, query_type: str, query: str) -> str:
        """规范化查询类型"""
        if query_type in ["repo", "code", "user", "topic"]:
            return query_type

        query_lower = query.lower()
        for type_name, keywords in self.valid_types.items():
            for keyword in keywords:
                if keyword in query_lower:
                    return type_name

        query_type_lower = query_type.lower()
        for type_name, keywords in self.valid_types.items():
            for keyword in keywords:
                if keyword in query_type_lower:
                    return type_name

View on GitHub (pinned to d6bde0fa54)

Solutions

  1. Read the text after '分析查询失败:' — it names the actual inner error (e.g. '无法提取query_type标签内容' means fix error 62)
  2. Reproduce with the same query string and inspect the debug prints emitted just before the raise
  3. Change the wrapper to 'raise ... from e' (or log e.__class__ and traceback) to keep the root cause
  4. Fix the inner error per its own diagnosis; the wrapper itself needs no direct fix

Example fix

// before
except Exception as e:
    raise Exception(f"分析查询失败: {str(e)}")

// after
except Exception as e:
    raise Exception(f"分析查询失败: {str(e)}") from e
Defensive patterns

Strategy: try-catch

Try / catch

try:
    criteria = analyzer.analyze(query)
except Exception as e:
    logger.exception("query analysis failed")  # full traceback; the wrapper loses it
    raise

Prevention

When it happens

Trigger: Any exception raised inside the analyze() method body: LLM call failures, tag extraction failures, None responses, invalid github_params structures, keyword argument mismatches when building SearchCriteria.

Common situations: First error users see when any part of the auto-git query analysis pipeline breaks; commonly triggered transitively by errors 60-62 when the LLM output is malformed.

Related errors


AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14). Data as JSON: /api/errors/dd22058e4c598822. Report an issue: GitHub.