{"record":{"id":"d8c00974d440685c","repo":"FujiwaraChoki/MoneyPrinterV2","slug":"unsupported-provider-provider-expected-twitt","errorCode":null,"errorMessage":"Unsupported provider '{provider}'. Expected 'twitter' or 'youtube'.","messagePattern":"Unsupported provider '(.+?)'\\. Expected 'twitter' or 'youtube'\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"src/cache.py","lineNumber":61,"sourceCode":"def get_provider_cache_path(provider: str) -> str:\n    \"\"\"\n    Gets the cache path for a supported account provider.\n\n    Args:\n        provider (str): The provider name (\"twitter\" or \"youtube\")\n\n    Returns:\n        path (str): The provider-specific cache path\n\n    Raises:\n        ValueError: If the provider is unsupported\n    \"\"\"\n    if provider == \"twitter\":\n        return get_twitter_cache_path()\n    if provider == \"youtube\":\n        return get_youtube_cache_path()\n\n    raise ValueError(f\"Unsupported provider '{provider}'. Expected 'twitter' or 'youtube'.\")\n\ndef get_accounts(provider: str) -> List[dict]:\n    \"\"\"\n    Gets the accounts from the cache.\n\n    Args:\n        provider (str): The provider to get the accounts for\n\n    Returns:\n        account (List[dict]): The accounts\n    \"\"\"\n    cache_path = get_provider_cache_path(provider)\n\n    if not os.path.exists(cache_path):\n        # Create the cache file\n        with open(cache_path, 'w') as file:\n            json.dump({\n                \"accounts\": []","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/FujiwaraChoki/MoneyPrinterV2/blob/5192af8eca97759f941834b947e3ceb209da0649/src/cache.py#L43-L79","documentation":"Raised by get_provider_cache_path when the provider string is neither 'twitter' nor 'youtube'. The cache layer only knows how to resolve paths for these two providers, so any other value is rejected before touching the filesystem.","triggerScenarios":"Calling get_accounts/add_account/remove_account with a provider value like 'instagram', 'Twitter' (capitalized), 'yt', or an empty string; passing user input through without normalizing it.","commonSituations":"Typos or case mismatches ('Twitter' vs 'twitter'), passing a provider read from config.json without validation, or new providers added to the app but not to src/cache.py.","solutions":["Normalize/lowercase the provider string before calling cache functions","Fix the caller to pass exactly 'twitter' or 'youtube'","If a new provider is intended, extend get_provider_cache_path with a matching path resolver"],"exampleFix":"// before\naccounts = get_accounts(\"Twitter\")\n\n// after\nprovider = provider.strip().lower()\nif provider not in (\"twitter\", \"youtube\"):\n    raise ValueError(f\"Unknown provider: {provider}\")\naccounts = get_accounts(provider)","handlingStrategy":"validation","validationCode":"provider = provider.strip().lower()\nif provider not in (\"twitter\", \"youtube\"):\n    raise ValueError(f\"Unsupported provider '{provider}'. Expected 'twitter' or 'youtube'.\")","typeGuard":"def is_supported_provider(provider: str) -> bool:\n    return isinstance(provider, str) and provider.strip().lower() in (\"twitter\", \"youtube\")","tryCatchPattern":null,"preventionTips":["Normalize provider strings to lowercase at the system boundary (CLI/config parsing)","Keep a single SUPPORTED_PROVIDERS tuple imported by all call sites instead of repeating literals","Reject unknown providers at config load time, not deep in cache code"],"tags":["python","validation","cache","provider"],"backgroundTag":"invalid-enum-value","analyzedSha":"5192af8eca97759f941834b947e3ceb209da0649","analyzedAt":"2026-08-28T10:31:46.474Z","schemaVersion":2},"datasetVersion":"2026-08-28T11:17:15.048Z"}