{"record":{"id":"8949115da39a8487","repo":"NanmiCoder/MediaCrawler","slug":"weibotorefactory-create-store-invalid-save-optio","errorCode":null,"errorMessage":"[WeibotoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...","messagePattern":"\\[WeibotoreFactory\\.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/weibo/__init__.py","lineNumber":51,"sourceCode":"\n\nclass WeibostoreFactory:\n    STORES = {\n        \"csv\": WeiboCsvStoreImplement,\n        \"db\": WeiboDbStoreImplement,\n        \"postgres\": WeiboDbStoreImplement,\n        \"json\": WeiboJsonStoreImplement,\n        \"jsonl\": WeiboJsonlStoreImplement,\n        \"sqlite\": WeiboSqliteStoreImplement,\n        \"mongodb\": WeiboMongoStoreImplement,\n        \"excel\": WeiboExcelStoreImplement,\n    }\n\n    @staticmethod\n    def create_store() -> AbstractStore:\n        store_class = WeibostoreFactory.STORES.get(config.SAVE_DATA_OPTION)\n        if not store_class:\n            raise ValueError(\"[WeibotoreFactory.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 batch_update_weibo_notes(note_list: List[Dict]):\n    \"\"\"\n    Batch update weibo notes\n    Args:\n        note_list:\n\n    Returns:\n\n    \"\"\"\n    if not note_list:\n        return\n    for note_item in note_list:\n        await update_weibo_note(note_item)\n\n","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/store/weibo/__init__.py#L33-L69","documentation":"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.","triggerScenarios":"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.","commonSituations":"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'.","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"],"exampleFix":"// before\nSAVE_DATA_OPTION = \"\"\n\n// after\nSAVE_DATA_OPTION = \"sqlite\"","handlingStrategy":"validation","validationCode":"from store.weibo import WeibostoreFactory\n\nif config.SAVE_DATA_OPTION not in WeibostoreFactory.STORES:\n    raise SystemExit(\n        f\"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; \"\n        f\"choose from {sorted(WeibostoreFactory.STORES)}\"\n    )","typeGuard":"def is_valid_save_option(opt: str) -> bool:\n    return isinstance(opt, str) and opt in WeibostoreFactory.STORES","tryCatchPattern":"try:\n    store = WeibostoreFactory.create_store()\nexcept ValueError as e:\n    raise SystemExit(f\"fix config before crawling: {e}\") from e","preventionTips":["Ensure SAVE_DATA_OPTION is non-empty after config refactors","'db' is the MySQL key","Validate all platform factories at startup in one place"],"tags":["configuration","storage","weibo","startup"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}