NanmiCoder/MediaCrawler · error · ValueError
[ZhihuStoreFactory.create_store] Invalid save option only su
Error message
[ZhihuStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...
What it means
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.
Source
Thrown at store/zhihu/__init__.py:54
class ZhihuStoreFactory:
STORES = {
"csv": ZhihuCsvStoreImplement,
"db": ZhihuDbStoreImplement,
"postgres": ZhihuDbStoreImplement,
"json": ZhihuJsonStoreImplement,
"jsonl": ZhihuJsonlStoreImplement,
"sqlite": ZhihuSqliteStoreImplement,
"mongodb": ZhihuMongoStoreImplement,
"excel": ZhihuExcelStoreImplement,
}
@staticmethod
def create_store() -> AbstractStore:
store_class = ZhihuStoreFactory.STORES.get(config.SAVE_DATA_OPTION)
if not store_class:
raise ValueError("[ZhihuStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...")
return store_class()
async def batch_update_zhihu_contents(contents: List[ZhihuContent]):
"""
Batch update Zhihu contents
Args:
contents:
Returns:
"""
if not contents:
return
for content_item in contents:
await update_zhihu_content(content_item)
async def update_zhihu_content(content_item: ZhihuContent):View on GitHub (pinned to d6f7c5bb90)
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
Example fix
// before SAVE_DATA_OPTION = "postgres " // after SAVE_DATA_OPTION = "postgres"
Defensive patterns
Strategy: validation
Validate before calling
from store.zhihu import ZhihuStoreFactory
if config.SAVE_DATA_OPTION not in ZhihuStoreFactory.STORES:
raise SystemExit(
f"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; "
f"choose from {sorted(ZhihuStoreFactory.STORES)}"
) Type guard
def is_valid_save_option(opt: str) -> bool:
return isinstance(opt, str) and opt in ZhihuStoreFactory.STORES Try / catch
try:
store = ZhihuStoreFactory.create_store()
except ValueError as e:
raise SystemExit(f"fix config before crawling: {e}") from e Prevention
- 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
When it happens
Trigger: 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.
Common situations: Shared SAVE_DATA_OPTION misconfigured once affects every platform including zhihu; configs ported from tutorials using outdated option names; accidental whitespace.
Related errors
- [BiliStoreFactory.create_store] Invalid save option only sup
- [DouyinStoreFactory.create_store] Invalid save option only s
- [KuaishouStoreFactory.create_store] Invalid save option only
- [TieBaStoreFactory.create_store] Invalid save option only su
- [WeibotoreFactory.create_store] Invalid save option only sup
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/ae10641acfbe5a85.
Report an issue: GitHub.