pulumi/pulumi · error · ValueError

empty component name in resource type: {resource_type}

Error message

empty component name in resource type: {resource_type}

What it means

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.

Source

Thrown at sdk/python/lib/pulumi/provider/experimental/component.py:367

    @staticmethod
    def validate_resource_type(pkg_name: str, resource_type: str) -> None:
        """
        Ensure that a resource type has the correct format and matches the
        package.
        """
        parts = resource_type.split(":")
        if len(parts) != 3:
            raise ValueError(f"invalid resource type: {resource_type}")
        if parts[0] != pkg_name:
            raise ValueError(f"invalid provider: {parts[0]}, expected {pkg_name}")
        # We might want to relax this limitation, but for now we only support the "index" module.
        if parts[1] not in ["index", ""]:
            raise ValueError(
                f"invalid modle '{parts[1]}' in resource type: {resource_type}, expected index or empty string"
            )
        component_name = parts[2]
        if len(component_name) == 0:
            raise ValueError(f"empty component name in resource type: {resource_type}")

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Supply the exact component (class) name as the third token segment
  2. Fix the code that builds the token so the component name is always included
  3. Validate token format before passing it to the provider (regex like ^[a-zA-Z0-9_.-]+:(index|):[a-zA-Z0-9_.-]+$)
  4. Reference the component class directly where possible instead of composing raw tokens

Example fix

# before
token = f"myprovider:index:{name}"  # name == ''
# after
if not name:
    raise ValueError("component name required")
token = f"myprovider:index:{name}"
Defensive patterns

Strategy: validation

Validate before calling

def validate_token_name(token: str) -> None:
    parts = token.split(":")
    if len(parts) == 3 and not parts[2]:
        raise ValueError(f"empty component name in token {token!r}")

Type guard

def has_component_name(tok: str) -> bool:
    parts = tok.split(":")
    return len(parts) == 3 and bool(parts[2])

Try / catch

try:
    resolve_component(token)
except ValueError as e:
    print(f"token '{token}' missing component name: {e}")
    raise

Prevention

When it happens

Trigger: Building tokens programmatically where the component name variable is empty or None, or truncating a token string during string manipulation.

Common situations: Dynamic token construction from config with a missing component key, slicing tokens incorrectly, templated IaC generating 'pkg:index:' with an unfilled placeholder.

Related errors


AI-assisted analysis of pulumi/pulumi@793f7b2e16 (2026-08-31). Data as JSON: /api/errors/73e59ade208c1fbd. Report an issue: GitHub.