pulumi/pulumi · error · ResourceError

Missing resource type argument

Error message

Missing resource type argument

What it means

Every Pulumi resource must be created with a type token (`t`), the first argument used to build the resource's URN. The Resource constructor throws this ResourceError when the type argument is missing/empty, because the engine cannot classify or register the resource without it.

Source

Thrown at sdk/nodejs/resource.ts:464

        props: Inputs = {},
        opts: ResourceOptions = {},
        remote: boolean = false,
        dependency: boolean = false,
        packageRef?: Promise<string | undefined>,
    ) {
        this.__pulumiType = t;

        if (dependency) {
            this.__providers = {};
            return;
        }

        if (opts.parent && !Resource.isInstance(opts.parent)) {
            throw new Error(`Resource parent is not a valid Resource: ${opts.parent}`);
        }

        if (!t) {
            throw new ResourceError("Missing resource type argument", opts.parent);
        }
        if (!name) {
            throw new ResourceError("Missing resource name argument (for URN creation)", opts.parent);
        }

        // Before anything else - if there are transformations registered, invoke them in order to transform the properties and
        // options assigned to this resource.
        const parent = opts.parent || getStackResource();
        this.__transformations = [...(opts.transformations || []), ...(parent?.__transformations || [])];
        for (const transformation of this.__transformations) {
            const tres = transformation({ resource: this, type: t, name, props, opts });
            if (tres) {
                if (tres.opts.parent !== opts.parent) {
                    // This is currently not allowed because the parent tree is needed to establish what
                    // transformation to apply in the first place, and to compute inheritance of other
                    // resource options in the Resource constructor before transformations are run (so
                    // modifying it here would only even partially take affect).  It's theoretically
                    // possible this restriction could be lifted in the future, but for now just

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Ensure `super(type, name, props, opts)` receives a non-empty type string like `"pkg:module:Name"`.
  2. Check that the variable holding the type token is defined at the call site.
  3. If writing a custom component, extend `ComponentResource` and pass a valid three-part type token.

Example fix

// before
class MyRes extends pulumi.CustomResource {
  constructor(name, opts) { super(undefined, name, {}, opts); }
}
// after
class MyRes extends pulumi.CustomResource {
  constructor(name, opts) { super("my:index:MyRes", name, {}, opts); }
}
Defensive patterns

Strategy: validation

Validate before calling

if (typeof type !== "string" || type.length === 0) {
  throw new TypeError("Resource type token (first constructor arg) must be a non-empty string like 'pkg:module:Name'");
}

Type guard

function isTypeToken(v: unknown): v is string {
  return typeof v === "string" && /^[a-zA-Z0-9-]+:[a-zA-Z0-9-]*:[a-zA-Z0-9-]+$/.test(v);
}

Try / catch

try {
  super(type, name, props, opts);
} catch (e) {
  if (e instanceof pulumi.ResourceError && /Missing resource type argument/.test(e.message)) {
    throw new Error("Subclass failed to forward a valid type token to super()");
  }
  throw e;
}

Prevention

When it happens

Trigger: Subclassing `Resource`/`CustomResource` and forgetting to forward the type token to `super`; calling `new CustomResource()` directly with undefined as the first argument; a component base class that drops the type parameter.

Common situations: Hand-written resource classes with broken super() calls; minified/bundled code that reorders arguments; dynamic type tokens computed from variables that end up undefined.

Related errors


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