{"record":{"id":"6970488faaaf528f","repo":"microsoft/autogen","slug":"invalid","errorCode":null,"errorMessage":"Invalid","messagePattern":"Invalid","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"python/packages/autogen-core/src/autogen_core/_component_config.py","lineNumber":252,"sourceCode":"\n        Returns:\n            Self | ExpectedType: The loaded component.\n        \"\"\"\n\n        # Use global and add further type checks\n\n        if isinstance(model, dict):\n            loaded_model = ComponentModel(**model)\n        else:\n            loaded_model = model\n\n        # First, do a look up in well known providers\n        if loaded_model.provider in WELL_KNOWN_PROVIDERS:\n            loaded_model.provider = WELL_KNOWN_PROVIDERS[loaded_model.provider]\n\n        output = loaded_model.provider.rsplit(\".\", maxsplit=1)\n        if len(output) != 2:\n            raise ValueError(\"Invalid\")\n\n        module_path, class_name = output\n\n        trusted = _get_trusted_namespaces()\n        # Also allow test modules (pytest convention) to load components\n        module_name = module_path.rsplit(\".\", maxsplit=1)[-1]\n        is_test_module = module_name.startswith(\"test_\") or module_path.startswith(\"test_\")\n        if not is_test_module and not any(\n            module_path.startswith(ns) or module_path == ns.rstrip(\".\") for ns in trusted\n        ):\n            raise ValueError(\n                f\"Provider module '{module_path}' is not in a trusted namespace. \"\n                f\"Allowed namespaces by default: autogen_core, autogen_agentchat, autogen_ext, \"\n                f\"autogen_studio, autogenstudio. \"\n                f\"To allow additional namespaces, set the AUTOGEN_ALLOWED_PROVIDER_NAMESPACES \"\n                f\"environment variable to a comma-separated list \"\n                f\"(e.g. AUTOGEN_ALLOWED_PROVIDER_NAMESPACES=mycompany_agents,mypackage).\"\n            )","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/microsoft/autogen/blob/027ecf0a379bcc1d09956d46d12d44a3ad9cee14/python/packages/autogen-core/src/autogen_core/_component_config.py#L234-L270","documentation":"When loading a component, the provider string is split on the last '.' to yield (module_path, class_name). A provider with no dot — e.g. a bare class name or malformed entry — fails rsplit and raises ValueError('Invalid'). The terse message (it should say something like 'provider must be module.Class') reflects a minimal guard before the trusted-namespace check.","triggerScenarios":"ComponentModel(provider=\"MyClass\", ...) or load_component with a dict where provider is \"MyClass\" instead of \"my_package.module.MyClass\"; provider strings built by string concatenation that dropped the module part; hand-written JSON configs with only the class name.","commonSituations":"Editing serialized component JSON by hand; generated configs from other tools that emit short provider names; provider typos replacing the dot.","solutions":["Use a fully qualified provider: \"my_package.module.ClassName\" (the exact string dump_component produces via _type_to_provider_str).","Round-trip a working instance through dump_component() and copy its provider field as the template.","If using a well-known short alias, verify it exists in WELL_KNOWN_PROVIDERS before substituting your own."],"exampleFix":"# before\nmodel = {\"provider\": \"MyComponent\", \"config\": {...}}\nComponentBase.load_component(model)  # ValueError: Invalid\n\n# after\nmodel = {\"provider\": \"my_package.components.MyComponent\", \"config\": {...}}\nComponentBase.load_component(model)","handlingStrategy":"validation","validationCode":"def is_qualified_provider(provider: str) -> bool:\n    return isinstance(provider, str) and len(provider.rsplit(\".\", maxsplit=1)) == 2 and all(provider.rsplit(\".\", maxsplit=1))\n\nassert is_qualified_provider(model[\"provider\"]), \"provider must be 'package.module.Class'\"","typeGuard":"def is_provider_string(v: object) -> TypeGuard[str]:\n    if not isinstance(v, str):\n        return False\n    parts = v.rsplit(\".\", maxsplit=1)\n    return len(parts) == 2 and all(p.isidentifier() for p in parts)","tryCatchPattern":"try:\n    obj = ComponentBase.load_component(model)\nexcept ValueError as e:\n    if str(e) == \"Invalid\":\n        raise ValueError(f\"provider {model['provider']!r} must be 'package.module.Class'\") from e\n    raise","preventionTips":["Generate provider strings with f\"{cls.__module__}.{cls.__qualname__}\" rather than hand-typing them.","Validate provider format in your config schema before calling load_component.","Round-trip once via dump_component to learn the exact provider format autogen expects."],"tags":["autogen-core","component-config","provider","config"],"backgroundTag":null,"analyzedSha":"027ecf0a379bcc1d09956d46d12d44a3ad9cee14","analyzedAt":"2026-08-15T03:38:00.719Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}