karatelabs/karate · warning

putMember() not implemented for

Error message

putMember() not implemented for: {} - {}

What it means

SimpleObject is an interface giving JS-interop objects a default putMember that only logs this warning and discards the value. Writing a member to an object that doesn't implement putMember is silently ignored (at WARN level) rather than throwing, so JS property assignments on such objects have no effect.

Solutions

  1. Don't assign properties on that object — store values in a karate variable or Map instead
  2. If you own the Java type, override putMember(String, Object) to actually store the value
  3. Check the logged class name to identify which object ignores the write

Example fix

// JS before
response.extra = 'x'; // warn, value discarded
// after
karate.set('extra', 'x');
// or Java side:
@Override public void putMember(String name, Object value) { map.put(name, value); }
Defensive patterns

Strategy: type-guard

Type guard

// avoid assigning on non-mutable objects; use a Map instead
function safeAssign(obj, key, val) { if (obj instanceof Java.type('java.util.Map')) obj.put(key, val); else karate.set(key, val); }

Prevention

When it happens

Trigger: JS code assigns a property (obj.foo = 1) on a Java object implementing SimpleObject (or ObjectLike falling back to the default) that does not override putMember.

Common situations: Assigning onto built-in/native objects (arrays, responses) from JS; library objects exposed read-only to scripts; users expecting mutable Java-backed objects in karate JS.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of karatelabs/karate@a22eb90246 (2026-09-12). Data as JSON: /api/errors/4f920fbc55c91203. Report an issue: GitHub.

Appendix: source

Thrown at karate-js/src/main/java/io/karatelabs/js/SimpleObject.java:43

import io.karatelabs.common.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;

public interface SimpleObject extends ObjectLike {

    Logger logger = LoggerFactory.getLogger(SimpleObject.class);

    String TO_STRING = "toString";

    @Override
    default void putMember(String name, Object value) {
        logger.warn("putMember() not implemented for: {} - {}", name, getClass().getName());
    }

    @Override
    default void removeMember(String name) {
        logger.warn("removeMember() not implemented for: {} - {}", name, getClass().getName());
    }

    @Override
    default Map<String, Object> toMap() {
        return toMap(jsKeys(), this);
    }

    default Collection<String> jsKeys() {
        logger.warn("jsKeys() not implemented for: {}", getClass().getName());
        return Collections.emptyList();
    }

    @Override

View on GitHub (pinned to a22eb90246)