{"record":{"id":"73e59ade208c1fbd","repo":"pulumi/pulumi","slug":"empty-component-name-in-resource-type-resource-t","errorCode":null,"errorMessage":"empty component name in resource type: {resource_type}","messagePattern":"empty component name in resource type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdk/python/lib/pulumi/provider/experimental/component.py","lineNumber":367,"sourceCode":"    @staticmethod\n    def validate_resource_type(pkg_name: str, resource_type: str) -> None:\n        \"\"\"\n        Ensure that a resource type has the correct format and matches the\n        package.\n        \"\"\"\n        parts = resource_type.split(\":\")\n        if len(parts) != 3:\n            raise ValueError(f\"invalid resource type: {resource_type}\")\n        if parts[0] != pkg_name:\n            raise ValueError(f\"invalid provider: {parts[0]}, expected {pkg_name}\")\n        # We might want to relax this limitation, but for now we only support the \"index\" module.\n        if parts[1] not in [\"index\", \"\"]:\n            raise ValueError(\n                f\"invalid modle '{parts[1]}' in resource type: {resource_type}, expected index or empty string\"\n            )\n        component_name = parts[2]\n        if len(component_name) == 0:\n            raise ValueError(f\"empty component name in resource type: {resource_type}\")\n","sourceCodeStart":349,"sourceCodeEnd":368,"githubUrl":"https://github.com/pulumi/pulumi/blob/793f7b2e160db4321fb7fb6b0607461e01cb251e/sdk/python/lib/pulumi/provider/experimental/component.py#L349-L368","documentation":"A validation ValueError thrown when the component-name segment (third colon-separated part) of a resource type token is empty, e.g. 'myprovider:index:'. Without a component name the provider cannot identify which component class to instantiate.","triggerScenarios":"Building tokens programmatically where the component name variable is empty or None, or truncating a token string during string manipulation.","commonSituations":"Dynamic token construction from config with a missing component key, slicing tokens incorrectly, templated IaC generating 'pkg:index:' with an unfilled placeholder.","solutions":["Supply the exact component (class) name as the third token segment","Fix the code that builds the token so the component name is always included","Validate token format before passing it to the provider (regex like ^[a-zA-Z0-9_.-]+:(index|):[a-zA-Z0-9_.-]+$)","Reference the component class directly where possible instead of composing raw tokens"],"exampleFix":"# before\ntoken = f\"myprovider:index:{name}\"  # name == ''\n# after\nif not name:\n    raise ValueError(\"component name required\")\ntoken = f\"myprovider:index:{name}\"","handlingStrategy":"validation","validationCode":"def validate_token_name(token: str) -> None:\n    parts = token.split(\":\")\n    if len(parts) == 3 and not parts[2]:\n        raise ValueError(f\"empty component name in token {token!r}\")","typeGuard":"def has_component_name(tok: str) -> bool:\n    parts = tok.split(\":\")\n    return len(parts) == 3 and bool(parts[2])","tryCatchPattern":"try:\n    resolve_component(token)\nexcept ValueError as e:\n    print(f\"token '{token}' missing component name: {e}\")\n    raise","preventionTips":["Never build tokens by slicing strings; use an f-string with a validated name variable","Assert component name is non-empty before token interpolation","Prefer direct class references over dynamic token strings"],"tags":["python","pulumi","resource-token","validation"],"backgroundTag":"invalid-resource-token","analyzedSha":"793f7b2e160db4321fb7fb6b0607461e01cb251e","analyzedAt":"2026-08-31T09:36:43.099Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}