pulumi/pulumi · error · TypeError

dependencies must be an Iterable[str] or None, got {type(dep

Error message

dependencies must be an Iterable[str] or None, got {type(dependencies).__name__}.

What it means

A TypeError raised by the property-value construction logic when the dependencies parameter is neither None nor an iterable of strings. Dependencies must be a list/collection of resource URN strings; anything else (non-iterable, or an iterable containing non-strings) is rejected.

Source

Thrown at sdk/python/lib/pulumi/provider/experimental/property_value.py:145

            or isinstance(value, Mapping)
            or isinstance(value, ResourceReference)
            or isinstance(value, Computed)
        ):
            raise TypeError(
                f"Unsupported value type: {type(value).__name__}. "
                f"Expected one of: None, bool, float, str, Asset, Archive, Sequence, Mapping, ResourceReference, or Computed."
            )

        # Validate is_secret parameter.
        if not isinstance(is_secret, bool):
            raise TypeError(
                f"is_secret must be a bool, got {type(is_secret).__name__}."
            )

        # Validate dependencies parameter.
        if dependencies is not None:
            if not isinstance(dependencies, Iterable):
                raise TypeError(
                    f"dependencies must be an Iterable[str] or None, got {type(dependencies).__name__}."
                )
            # Validate that all items in dependencies are strings.
            for dep in dependencies:
                if not isinstance(dep, str):
                    raise TypeError(
                        f"All dependencies must be strings, found {type(dep).__name__}."
                    )

        # Validate Sequence and Mapping types and wrap in immutable types to ensure they are hashable.
        if isinstance(value, Sequence) and not isinstance(value, str):
            # Validate all items in the sequence are PropertyValue instances.
            for i, item in enumerate(value):
                if not isinstance(item, PropertyValue):
                    raise TypeError(
                        f"Sequence items must be PropertyValue instances, found {type(item).__name__} at index {i}."
                    )
            value = tuple(value)

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Pass a list of URN strings, e.g. [res.urn] rather than res or res.urn
  2. Map resource objects to their URNs: dependencies=[r.urn for r in resources]
  3. If there are no dependencies, pass None explicitly
  4. Pre-validate with a check that all items are strings before calling the API

Example fix

# before
make_value(x, dependencies=res.urn)  # a single string
# after
make_value(x, dependencies=[res.urn])
Defensive patterns

Strategy: type-guard

Validate before calling

def check_dependencies(deps) -> None:
    if deps is None:
        return
    if not isinstance(deps, (list, tuple)) or not all(isinstance(d, str) for d in deps):
        raise TypeError("dependencies must be a list of URN strings or None")

Type guard

def is_urn_list(v) -> bool:
    return v is None or (isinstance(v, (list, tuple)) and all(isinstance(d, str) for d in v))

Try / catch

try:
    make_property_value(value, dependencies=deps)
except TypeError as e:
    print(f"fix dependencies (use [res.urn] or None): {e}")
    raise

Prevention

When it happens

Trigger: Calling the property-value wrapper with dependencies set to a single string instead of a list of strings, a dict, or a list containing non-string items like resource objects or ints.

Common situations: Passing a bare URN string (strings are iterable but their items are chars, caught by the per-item str check), passing Pulumi resource objects instead of their .urn values, deserialized JSON where dependencies came through as something else.

Understand the failure class

Background: Invalid argument type errors: "must be of type string", "expected X, got Y", and ERR_INVALID_ARG_TYPE explained — this error's family across 15 libraries.

Related errors


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