{"record":{"id":"f11d0ca2fd2b86eb","repo":"crewAIInc/crewAI","slug":"provider-is-required","errorCode":null,"errorMessage":"provider is required","messagePattern":"provider is required","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/crewai-files/src/crewai_files/formatting/api.py","lineNumber":36,"sourceCode":"from crewai_files.processing.processor import FileProcessor\nfrom crewai_files.resolution.resolver import FileResolver, FileResolverConfig\nfrom crewai_files.uploaders.factory import ProviderType\n\n\ndef _normalize_provider(provider: str | None) -> ProviderType:\n    \"\"\"Normalize provider string to ProviderType.\n\n    Args:\n        provider: Raw provider string.\n\n    Returns:\n        Normalized provider type.\n\n    Raises:\n        ValueError: If provider is None or empty.\n    \"\"\"\n    if not provider:\n        raise ValueError(\"provider is required\")\n\n    provider_lower = provider.lower()\n\n    if \"gemini\" in provider_lower:\n        return \"gemini\"\n    if \"google\" in provider_lower:\n        return \"google\"\n    if \"anthropic\" in provider_lower:\n        return \"anthropic\"\n    if \"claude\" in provider_lower:\n        return \"claude\"\n    if \"bedrock\" in provider_lower:\n        return \"bedrock\"\n    if \"aws\" in provider_lower:\n        return \"aws\"\n    if \"azure\" in provider_lower:\n        return \"azure\"\n    if \"gpt\" in provider_lower:","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/crewAIInc/crewAI/blob/754d7323beb2fd042e33444a115ea2d5a47193f0/lib/crewai-files/src/crewai_files/formatting/api.py#L18-L54","documentation":"Thrown by normalize_provider() in crewai_files.formatting.api when the provider argument is None or an empty string. The library needs a provider name to select the correct formatter (gemini, google, anthropic, claude, bedrock, etc.), so it refuses to guess and raises ValueError('provider is required'). It is a caller-side programming error, not an environment issue.","triggerScenarios":"Calling the formatting API entry point with provider=None, provider=\"\", or provider=\"   \" (any falsy value; note whitespace-only strings pass this check but then fall through the substring matching). Typically happens when the provider is read from an optional config field or dict that was never populated.","commonSituations":"Optional provider key missing from a config dict (config.get(\"provider\") returns None); env var like os.environ.get(\"LLM_PROVIDER\") unset; a default parameter left as None and forwarded unchecked; refactoring that dropped the provider argument.","solutions":["Pass a non-empty provider string such as \"anthropic\", \"openai\", \"google\", \"gemini\", \"bedrock\" or \"vertex_ai\" (matching is case-insensitive substring based).","If the provider comes from config, give it a default: provider = config.get(\"provider\") or \"openai\".","Validate at the boundary of your app (fail fast on startup) rather than deep in the formatting call.","Add a unit test asserting ValueError is raised for None/empty so the contract stays locked."],"exampleFix":"// before\nprovider = config.get(\"provider\")  # None when key missing\nformatter = get_formatter(provider, ...)\n\n# after\nprovider = config.get(\"provider\")\nif not provider:\n    raise ValueError(\"config must define 'provider'\")\nformatter = get_formatter(provider, ...)","handlingStrategy":"validation","validationCode":"provider = config.get(\"provider\")\nif not provider or not provider.strip():\n    raise ValueError(\"config must define a non-empty 'provider'\")","typeGuard":"def is_valid_provider(provider: object) -> TypeGuard[str]:\n    return isinstance(provider, str) and bool(provider.strip())","tryCatchPattern":"try:\n    formatter_api = build(provider)\nexcept ValueError as e:\n    if \"provider is required\" in str(e):\n        raise ConfigError(\"LLM provider not configured\") from e\n    raise","preventionTips":["Fail fast on startup: assert required config keys like provider before any agent runs.","Give config reads explicit defaults (config.get('provider') or 'openai').","Never forward Optional[str] fields unchecked into the formatting API."],"tags":["validation","provider","configuration","valueerror"],"backgroundTag":null,"analyzedSha":"754d7323beb2fd042e33444a115ea2d5a47193f0","analyzedAt":"2026-08-15T04:06:56.746Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}