sansan0/TrendRadar · critical · CrawlTaskError

CRAWL_TASK_ERROR

CRAWL_TASK_ERROR

Error message

配置文件不存在

What it means

Thrown by _load_crawl_config in the system tools when config/config.yaml does not exist under project_root. This is a hard prerequisite: the hot-list crawl tasks read platform definitions, credentials, and feature toggles from this file before doing anything else.

Source

Thrown at mcp_server/tools/system.py:78

                "success": False,
                "error": e.to_dict()
            }
        except Exception as e:
            return {
                "success": False,
                "error": {
                    "code": "INTERNAL_ERROR",
                    "message": str(e)
                }
            }

    def _load_crawl_config(self):
        """加载爬取配置,返回 (config_data, target_platforms_config)"""
        import yaml

        config_path = self.project_root / "config" / "config.yaml"
        if not config_path.exists():
            raise CrawlTaskError(
                "配置文件不存在",
                suggestion=f"请确保配置文件存在: {config_path}"
            )

        with open(config_path, "r", encoding="utf-8") as f:
            config_data = yaml.safe_load(f)

        platforms_config = config_data.get("platforms", {})
        if not platforms_config.get("enabled", True):
            raise CrawlTaskError(
                "热榜平台已禁用",
                suggestion="请检查 config/config.yaml 中的 platforms.enabled 配置"
            )
        all_platforms = [p for p in platforms_config.get("sources", []) if p.get("enabled", True)]
        if not all_platforms:
            raise CrawlTaskError(
                "配置文件中没有平台配置",
                suggestion="请检查 config/config.yaml 中的 platforms.sources 配置"

View on GitHub (pinned to 8ee26026ba)

Solutions

  1. Create config/config.yaml under the project root (copy from the repo's example config if provided)
  2. Verify project_root points at the actual repository when launching the MCP server from another directory
  3. In deployments, mount/bake the config file into the image or volume

Example fix

# before: file missing
# $ ls config/
# (empty)

# after
 cp config/config.example.yaml config/config.yaml
 # then edit platforms/credential entries
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path

def crawl_config_ready(project_root: Path) -> bool:
    return (project_root / "config" / "config.yaml").is_file()

if not crawl_config_ready(PROJECT_ROOT):
    raise RuntimeError("config/config.yaml missing — run setup first")

Type guard

def is_existing_file(p) -> bool:
    from pathlib import Path
    try:
        return Path(p).is_file()
    except (TypeError, ValueError):
        return False

Try / catch

try:
    run_crawl_task()
except CrawlTaskError as e:
    if "配置文件不存在" in str(e):
        # deployment issue: surface to operator, do not retry blindly
        raise RuntimeError(f"crawl config missing at {e.suggestion}") from e
    raise

Prevention

When it happens

Trigger: Running a crawl-trigger MCP tool in a checkout where config/config.yaml was never created (usually it is gitignored and must be copied from an example), or when project_root is mis-detected (launched from a different working directory).

Common situations: Fresh clone without running the setup step that copies config.example.yaml; deploying a container without mounting the config directory; CWD-dependent project_root resolution.

Related errors


AI-assisted analysis of sansan0/TrendRadar@8ee26026ba (2026-08-15). Data as JSON: /api/errors/43d0b09659196276. Report an issue: GitHub.