NanmiCoder/MediaCrawler · error · ValueError
[WeibotoreFactory.create_store] Invalid save option only sup
Error message
[WeibotoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...
What it means
Raised by WeibostoreFactory.create_store() when config.SAVE_DATA_OPTION is not in the weibo STORES registry (csv, db, postgres, json, jsonl, sqlite, mongodb, excel). Same fail-fast factory pattern as the other platforms; note the class name and message contain an internal typo ('WeibotoreFactory') but behavior is identical.
Source
Thrown at store/weibo/__init__.py:51
class WeibostoreFactory:
STORES = {
"csv": WeiboCsvStoreImplement,
"db": WeiboDbStoreImplement,
"postgres": WeiboDbStoreImplement,
"json": WeiboJsonStoreImplement,
"jsonl": WeiboJsonlStoreImplement,
"sqlite": WeiboSqliteStoreImplement,
"mongodb": WeiboMongoStoreImplement,
"excel": WeiboExcelStoreImplement,
}
@staticmethod
def create_store() -> AbstractStore:
store_class = WeibostoreFactory.STORES.get(config.SAVE_DATA_OPTION)
if not store_class:
raise ValueError("[WeibotoreFactory.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_weibo_notes(note_list: List[Dict]):
"""
Batch update weibo notes
Args:
note_list:
Returns:
"""
if not note_list:
return
for note_item in note_list:
await update_weibo_note(note_item)
View on GitHub (pinned to d6f7c5bb90)
Solutions
- Set SAVE_DATA_OPTION to a valid registry key: csv, db, postgres, json, jsonl, sqlite, mongodb, excel
- Ensure the value is non-empty — an empty config string also lands here
- Use 'db' (not 'mysql') for the MySQL-backed store, and set the MySQL connection env vars accordingly
- Centralize validation: check the option once at startup against all platform registries to fail before crawling starts
Example fix
// before SAVE_DATA_OPTION = "" // after SAVE_DATA_OPTION = "sqlite"
Defensive patterns
Strategy: validation
Validate before calling
from store.weibo import WeibostoreFactory
if config.SAVE_DATA_OPTION not in WeibostoreFactory.STORES:
raise SystemExit(
f"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; "
f"choose from {sorted(WeibostoreFactory.STORES)}"
) Type guard
def is_valid_save_option(opt: str) -> bool:
return isinstance(opt, str) and opt in WeibostoreFactory.STORES Try / catch
try:
store = WeibostoreFactory.create_store()
except ValueError as e:
raise SystemExit(f"fix config before crawling: {e}") from e Prevention
- Ensure SAVE_DATA_OPTION is non-empty after config refactors
- 'db' is the MySQL key
- Validate all platform factories at startup in one place
When it happens
Trigger: SAVE_DATA_OPTION is any string not in the registry — 'mysql', 'xlsx', 'CSV', '' (empty), or a value from incompatible forks — when the weibo crawler instantiates its store.
Common situations: Empty SAVE_DATA_OPTION after a config refactor; case-sensitive mismatch; user assumes 'mysql' is the key for the MySQL implementation when it is 'db'.
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
- [XhsStoreFactory.create_store] Invalid save option only supp
AI-assisted analysis of NanmiCoder/MediaCrawler@d6f7c5bb90 (2026-08-15).
Data as JSON: /api/errors/8949115da39a8487.
Report an issue: GitHub.