{"record":{"id":"122aaa51a755e5c7","repo":"NanmiCoder/MediaCrawler","slug":"kuaishoustorefactory-create-store-invalid-save-o","errorCode":null,"errorMessage":"[KuaishouStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...","messagePattern":"\\[KuaishouStoreFactory\\.create_store\\] Invalid save option only supported csv or db or json or sqlite or mongodb or excel \\.\\.\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"store/kuaishou/__init__.py","lineNumber":50,"sourceCode":"\n\nclass KuaishouStoreFactory:\n    STORES = {\n        \"csv\": KuaishouCsvStoreImplement,\n        \"db\": KuaishouDbStoreImplement,\n        \"postgres\": KuaishouDbStoreImplement,\n        \"json\": KuaishouJsonStoreImplement,\n        \"jsonl\": KuaishouJsonlStoreImplement,\n        \"sqlite\": KuaishouSqliteStoreImplement,\n        \"mongodb\": KuaishouMongoStoreImplement,\n        \"excel\": KuaishouExcelStoreImplement,\n    }\n\n    @staticmethod\n    def create_store() -> AbstractStore:\n        store_class = KuaishouStoreFactory.STORES.get(config.SAVE_DATA_OPTION)\n        if not store_class:\n            raise ValueError(\n                \"[KuaishouStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...\")\n        return store_class()\n\n\nasync def update_kuaishou_video(video_item: Dict):\n    photo_info: Dict = video_item.get(\"photo\", {})\n    video_id = photo_info.get(\"id\")\n    if not video_id:\n        return\n    user_info = video_item.get(\"author\", {})\n    save_content_item = {\n        \"video_id\": video_id,\n        \"video_type\": str(video_item.get(\"type\")),\n        \"title\": photo_info.get(\"caption\", \"\")[:500],\n        \"desc\": photo_info.get(\"caption\", \"\")[:500],\n        \"create_time\": photo_info.get(\"timestamp\"),\n        \"creator_hash\": anonymize_user_id(user_info.get(\"id\")),  # 创作者匿名哈希(不存原始 user_id)\n        \"nickname\": mask_nickname(user_info.get(\"name\")),  # 用户昵称(已脱敏)","sourceCodeStart":32,"sourceCodeEnd":68,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/store/kuaishou/__init__.py#L32-L68","documentation":"Raised by KuaishouStoreFactory.create_store() when config.SAVE_DATA_OPTION is not found in the kuaishou STORES registry (csv, db, postgres, json, jsonl, sqlite, mongodb, excel). Startup-time guard preventing a kuaishou crawl from running with an unimplemented persistence backend.","triggerScenarios":"SAVE_DATA_OPTION contains a value like 'mysql', 'xlsx', or any string outside the registry; raised on the first store instantiation when the kuaishou crawler begins persisting results.","commonSituations":"Config edited for one platform's docs but reused globally (SAVE_DATA_OPTION is shared across all platforms); typo or uppercase value; value valid in an older project version.","solutions":["Set SAVE_DATA_OPTION to a registered key: csv, db, postgres, json, jsonl, sqlite, mongodb, excel","Remember the option is global — changing it for kuaishou changes it for every platform factory","Validate the config early: assert config.SAVE_DATA_OPTION in expected set at app start rather than failing mid-crawl","For quick local runs use 'json' or 'sqlite' (no external services needed)"],"exampleFix":"// before\nSAVE_DATA_OPTION = \"MySQL\"\n\n// after\nSAVE_DATA_OPTION = \"db\"  # exact, lowercase registry key","handlingStrategy":"validation","validationCode":"from store.kuaishou import KuaishouStoreFactory\n\nif config.SAVE_DATA_OPTION not in KuaishouStoreFactory.STORES:\n    raise SystemExit(\n        f\"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; \"\n        f\"choose from {sorted(KuaishouStoreFactory.STORES)}\"\n    )","typeGuard":"def is_valid_save_option(opt: str) -> bool:\n    return isinstance(opt, str) and opt in KuaishouStoreFactory.STORES","tryCatchPattern":"try:\n    store = KuaishouStoreFactory.create_store()\nexcept ValueError as e:\n    raise SystemExit(f\"fix config before crawling: {e}\") from e","preventionTips":["Validate the option once globally; all platform registries share the same keys","Beware case sensitivity and whitespace","Default to json/sqlite unless infrastructure for db/mongodb exists"],"tags":["configuration","storage","kuaishou","startup"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}