{"record":{"id":"7cbf2a2afa82001a","repo":"karatelabs/karate","slug":"cannot-create-property-name-on-typeof-receiver","errorCode":null,"errorMessage":"cannot create property '${name}' on ${typeOf(receiver)}","messagePattern":"cannot create property '(.+?)' on (.+?)","errorType":"exception","errorClass":"JsErrorException (typeError)","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/js/PropertyAccess.java","lineNumber":1186,"sourceCode":"            }\n            if (receiver != object) {\n                if (receiver instanceof ObjectLike receiverObj) {\n                    // super data write: no accessor anywhere on the base's\n                    // chain, so the property is created/updated on the\n                    // instance. putMember on the receiver still honors an own\n                    // accessor and writable=false there (the spec's\n                    // receiver-side checks).\n                    Object oldValue = receiverObj.getMember(name);\n                    receiverObj.putMember(name, value, context, context.strict);\n                    firePropertySet(context, name, value, oldValue, receiver, trackingNode);\n                    return;\n                }\n                // Non-object receiver (a super write with a primitive `this`,\n                // e.g. B.prototype.m.call(3)): the write can neither create a\n                // property on the primitive nor be allowed to land on the\n                // shared prototype. Strict: TypeError; sloppy: silent no-op.\n                if (context.strict) {\n                    throw JsErrorException.typeError(\n                            \"cannot create property '\" + name + \"' on \" + Terms.typeOf(receiver));\n                }\n                return;\n            }\n            Object oldValue = objectLike.getMember(name);\n            objectLike.putMember(name, value, context, context.strict);\n            firePropertySet(context, name, value, oldValue, object, trackingNode);\n        } else if (object instanceof Map) {\n            Map<String, Object> map = (Map<String, Object>) object;\n            Object oldValue = map.get(name);\n            map.put(name, value);\n            firePropertySet(context, name, value, oldValue, object, trackingNode);\n        } else if (context.root.bridge != null) {\n            try {\n                if (object instanceof ExternalAccess ja) {\n                    ja.setProperty(name, value);\n                } else {\n                    ExternalAccess ja = context.root.bridge.forInstance(object);","sourceCodeStart":1168,"sourceCodeEnd":1204,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/js/PropertyAccess.java#L1168-L1204","documentation":"Mirrors the ECMAScript strict-mode rule for property creation on primitives: a `super` write whose `this` is a primitive (e.g. `B.prototype.m.call(3)`) cannot create a new property, so in strict mode Karate throws this TypeError; in sloppy mode it silently ignores the write. It only fires for property creation on a non-object receiver during a super-property set.","triggerScenarios":"Calling a class/prototype method with `.call(<primitive>)` / `.apply(<primitive>)` where the method performs `super.x = value` (creating a new property on the super target's receiver), while strict mode is enabled in the embedded JS engine.","commonSituations":"Porting real JavaScript class hierarchies into Karate JS and invoking methods with a primitive this (numbers, strings, booleans) instead of an object instance.","solutions":["Call the method with a proper object receiver: `B.prototype.m.call(obj)` where obj is an object, not a primitive.","Use `new` to create an instance instead of borrowing the method with a primitive this.","Wrap/beforehand-coerce the receiver: `Object(3)` so the receiver is a boxed object.","If the write is intentionally a no-op, run without strict mode (sloppy mode ignores it)."],"exampleFix":"// before\n* eval B.prototype.m.call(3)\n// after\n* eval B.prototype.m.call(new B())","handlingStrategy":"validation","validationCode":"// ensure receiver is an object before method borrow\nif (typeof recv !== 'object' || recv === null) recv = Object(recv);","typeGuard":"function isObjectReceiver(v) { return v !== null && (typeof v === 'object' || typeof v === 'function'); }","tryCatchPattern":null,"preventionTips":["Never borrow super-writing methods with primitive this.","Instantiate classes with new instead of .call(primitive).","Box primitives with Object() when borrowing methods.","Keep class-hierarchy code in strict-mode-clean form."],"tags":["javascript","type-error","strict-mode","super","primitive-receiver"],"backgroundTag":"invalid-argument-value","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-19T12:17:13.211Z"}