{"record":{"id":"0d80486a636ce4e3","repo":"NanmiCoder/MediaCrawler","slug":"tiebastorefactory-create-store-invalid-save-opti","errorCode":null,"errorMessage":"[TieBaStoreFactory.create_store] Invalid save option only supported csv or db or json or sqlite or mongodb or excel ...","messagePattern":"\\[TieBaStoreFactory\\.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/tieba/__init__.py","lineNumber":46,"sourceCode":"\n\nclass TieBaStoreFactory:\n    STORES = {\n        \"csv\": TieBaCsvStoreImplement,\n        \"db\": TieBaDbStoreImplement,\n        \"postgres\": TieBaDbStoreImplement,\n        \"json\": TieBaJsonStoreImplement,\n        \"jsonl\": TieBaJsonlStoreImplement,\n        \"sqlite\": TieBaSqliteStoreImplement,\n        \"mongodb\": TieBaMongoStoreImplement,\n        \"excel\": TieBaExcelStoreImplement,\n    }\n\n    @staticmethod\n    def create_store() -> AbstractStore:\n        store_class = TieBaStoreFactory.STORES.get(config.SAVE_DATA_OPTION)\n        if not store_class:\n            raise ValueError(\n                \"[TieBaStoreFactory.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_tieba_notes(note_list: List[TiebaNote]):\n    \"\"\"\n    Batch update tieba 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_tieba_note(note_item)\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/NanmiCoder/MediaCrawler/blob/d6f7c5bb906b6dac40ddf343ef9e26438a3de092/store/tieba/__init__.py#L28-L64","documentation":"Raised by TieBaStoreFactory.create_store() when config.SAVE_DATA_OPTION is not a key in the tieba STORES registry (csv, db, postgres, json, jsonl, sqlite, mongodb, excel). Fail-fast so an unknown backend is rejected before any tieba note data is written.","triggerScenarios":"SAVE_DATA_OPTION set to a non-registry string (typo, wrong case, 'mysql' instead of 'db') and a tieba crawler run starts; raised at the first create_store() call.","commonSituations":"Copying SAVE_DATA_OPTION from another tool's docs; stale config after upgrading to a version that renamed options; whitespace or quotes accidentally included in the value.","solutions":["Use exactly one of: csv, db, postgres, json, jsonl, sqlite, mongodb, excel","Print the effective value at startup to catch env-var overrides: python -c 'import config; print(repr(config.SAVE_DATA_OPTION))'","Pick 'sqlite' or 'json' for dependency-free local crawling","Add the missing backend to TieBaStoreFactory.STORES only if you implement an AbstractStore subclass for it"],"exampleFix":"// before\nSAVE_DATA_OPTION = \"json \"\n\n// after\nSAVE_DATA_OPTION = \"json\"","handlingStrategy":"validation","validationCode":"from store.tieba import TieBaStoreFactory\n\nif config.SAVE_DATA_OPTION not in TieBaStoreFactory.STORES:\n    raise SystemExit(\n        f\"SAVE_DATA_OPTION={config.SAVE_DATA_OPTION!r} invalid; \"\n        f\"choose from {sorted(TieBaStoreFactory.STORES)}\"\n    )","typeGuard":"def is_valid_save_option(opt: str) -> bool:\n    return isinstance(opt, str) and opt in TieBaStoreFactory.STORES","tryCatchPattern":"try:\n    store = TieBaStoreFactory.create_store()\nexcept ValueError as e:\n    raise SystemExit(f\"fix config before crawling: {e}\") from e","preventionTips":["Fail at startup with a clear message instead of mid-crawl","Use repr() when debugging config values","Keep a single source of truth for valid options and validate against it"],"tags":["configuration","storage","tieba","startup"],"backgroundTag":null,"analyzedSha":"d6f7c5bb906b6dac40ddf343ef9e26438a3de092","analyzedAt":"2026-08-15T01:39:07.505Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}