{"record":{"id":"ae10641acfbe5a85","repo":"NanmiCoder/MediaCrawler","slug":"zhihustorefactory-create-store-invalid-save-opti","errorCode":null,"errorMessage":"[ZhihuStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...","messagePattern":"\\[ZhihuStoreFactory\\.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/zhihu/__init__.py","lineNumber":54,"sourceCode":"\n\nclass ZhihuStoreFactory:\n    STORES = {\n        \"csv\": ZhihuCsvStoreImplement,\n        \"db\": ZhihuDbStoreImplement,\n        \"postgres\": ZhihuDbStoreImplement,\n        \"json\": ZhihuJsonStoreImplement,\n        \"jsonl\": ZhihuJsonlStoreImplement,\n        \"sqlite\": ZhihuSqliteStoreImplement,\n        \"mongodb\": ZhihuMongoStoreImplement,\n        \"excel\": ZhihuExcelStoreImplement,\n    }\n\n    @staticmethod\n    def create_store() -> AbstractStore:\n        store_class = ZhihuStoreFactory.STORES.get(config.SAVE_DATA_OPTION)\n        if not store_class:\n            raise ValueError(\"[ZhihuStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...\")\n        return store_class()\n\nasync def batch_update_zhihu_contents(contents: List[ZhihuContent]):\n    \"\"\"\n    Batch update Zhihu contents\n    Args:\n        contents:\n\n    Returns:\n\n    \"\"\"\n    if not contents:\n        return\n\n    for content_item in contents:\n        await update_zhihu_content(content_item)\n\nasync def update_zhihu_content(content_item: ZhihuContent):","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/store/zhihu/__init__.py#L36-L72","documentation":"Raised by ZhihuStoreFactory.create_store() when config.SAVE_DATA_OPTION is not found in the zhihu STORES registry (csv, db, postgres, json, jsonl, sqlite, mongodb, excel). Standard fail-fast factory guard: the zhihu crawler will not start persisting with an unknown backend.","triggerScenarios":"SAVE_DATA_OPTION contains a non-registry string (typo, case mismatch, 'mysql' for MySQL instead of 'db') when the zhihu crawler first creates its store.","commonSituations":"Shared SAVE_DATA_OPTION misconfigured once affects every platform including zhihu; configs ported from tutorials using outdated option names; accidental whitespace.","solutions":["Set SAVE_DATA_OPTION to one of: csv, db, postgres, json, jsonl, sqlite, mongodb, excel","Verify with repr() to expose hidden whitespace: print(repr(config.SAVE_DATA_OPTION))","Use sqlite/json for runs without infrastructure; db/postgres/mongodb only after their env vars are set","Fail early: validate the option in your entrypoint before launching the crawler"],"exampleFix":"// before\nSAVE_DATA_OPTION = \"postgres \"\n\n// after\nSAVE_DATA_OPTION = \"postgres\"","handlingStrategy":"validation","validationCode":"from store.zhihu import ZhihuStoreFactory\n\nif config.SAVE_DATA_OPTION not in ZhihuStoreFactory.STORES:\n    raise SystemExit(\n        f\"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; \"\n        f\"choose from {sorted(ZhihuStoreFactory.STORES)}\"\n    )","typeGuard":"def is_valid_save_option(opt: str) -> bool:\n    return isinstance(opt, str) and opt in ZhihuStoreFactory.STORES","tryCatchPattern":"try:\n    store = ZhihuStoreFactory.create_store()\nexcept ValueError as e:\n    raise SystemExit(f\"fix config before crawling: {e}\") from e","preventionTips":["One shared SAVE_DATA_OPTION governs all platforms — validate it once centrally","Trim/normalize the value when loading config","Prefer built-in backends unless external stores are configured"],"tags":["configuration","storage","zhihu","startup"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}