pulumi/pulumi · error · Error

error serializing property "${k}": ${String(err)}

Error message

error serializing property "${k}": ${String(err)}

What it means

When serializing a resource's input properties to send to the engine, the SDK wraps any exception raised while serializing property `k` into an error prefixed with `error serializing property "k": ...`. This preserves the original error (if it's an Error instance) while telling you which property failed. The underlying cause is usually a value the serializer cannot handle, or a promise/output rejection inside the property value.

Source

Thrown at sdk/nodejs/runtime/rpc.ts:195

    for (const k of Object.keys(props)) {
        if (acceptKey(k)) {
            if (opts?.pendingRegistration !== undefined) {
                opts.pendingRegistration.inputProperty = k;
            }
            // We treat properties with undefined values as if they do not exist.
            const dependentResources = new Set<Resource>();
            let v;
            try {
                v = await serializeProperty(`${label}.${k}`, props[k], dependentResources, opts);
            } catch (err) {
                // Augment the message with the property name, but rethrow the *same* error so its identity is
                // preserved: our uncaught handler dedupes reported errors by identity, and the same rejection can
                // surface from more than one awaiter.
                if (err instanceof Error) {
                    err.message = `error serializing property "${k}": ${err.message}`;
                    throw err;
                }
                throw new Error(`error serializing property "${k}": ${String(err)}`);
            }
            if (v !== undefined) {
                result[k] = v;
                propertyToDependentResources.set(k, dependentResources);
            }
        }
    }

    return [result, propertyToDependentResources];
}

/**
 * Walks the props object passed in, awaiting all interior promises besides
 * those for `id` and `urn`, creating a reasonable POJO object that can be
 * remoted over to {@link registerResource}.
 */
export async function serializeResourceProperties(label: string, props: Inputs, opts?: SerializationOptions) {
    return serializeFilteredProperties(label, props, (key) => key !== "id" && key !== "urn", opts);

View on GitHub (pinned to 793f7b2e16)

Solutions

  1. Read the wrapped inner error after the prefix to identify the offending value type, then remove or convert that value in the failing property.
  2. Wrap non-serializable values as strings, JSON-serializable plain objects, or `pulumi.Output` of such values.
  3. If the property is a rejected Promise/Output, fix the code that computes it so it resolves or handles its own error.
  4. Break cyclic references before passing data as inputs.

Example fix

// before
new Provider("p", { client: dbClient }); // non-serializable class instance
// after
new Provider("p", { client: pulumi.output(dbClient.name) }); // serialize a plain value
Defensive patterns

Strategy: try-catch

Validate before calling

function isSerializable(v) {
  return v === null || typeof v !== 'object' || v instanceof pulumi.Output ||
    !(typeof v === 'function' || v.constructor !== Object && !Array.isArray(v) && !(v instanceof Promise));
}

Type guard

function isPlainSerializable(v: unknown): boolean {
  return v === null || ['string','number','boolean'].includes(typeof v) ||
    v instanceof pulumi.Output || v instanceof Promise || Array.isArray(v) ||
    (typeof v === 'object' && Object.getPrototypeOf(v) === Object.prototype);
}

Try / catch

try {
  await serializeProps(props);
} catch (err) {
  const m = /error serializing property "([^"]+)"/.exec(err.message);
  if (m) console.error(`Fix input property '${m[1]}': ${err.message}`);
  throw err;
}

Prevention

When it happens

Trigger: Passing a value to a resource's props that `serializeProperty` cannot encode: unsupported types (functions, symbols, class instances without marshaling support), a Promise that rejects, an Output whose underlying value throws during serialization, or cyclic references inside an object/array property.

Common situations: Passing a callback or a non-serializable object (e.g. a database handle, a class instance) as a resource input; a computed Output whose value throws; deeply nested config objects containing unsupported types; cyclic data structures built from config.

Related errors


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