{"record":{"id":"9d0e5c6a58863c86","repo":"karatelabs/karate","slug":"cannot-delete-property-name-of-object-object","errorCode":null,"errorMessage":"Cannot delete property '{name}' of [object Object]","messagePattern":"Cannot delete property '(.+?)' of \\[object Object\\]","errorType":"exception","errorClass":"JsErrorException","httpStatus":null,"severity":"error","filePath":"karate-js/src/main/java/io/karatelabs/js/JsObject.java","lineNumber":488,"sourceCode":"    /** True iff {@code name} has a non-tombstoned own slot (excludes intrinsics). */\n    boolean ownContainsKey(String name) {\n        PropertySlot s = props == null ? null : props.get(name);\n        return s != null && !s.tombstoned;\n    }\n\n    /** Strict-mode [[Set]] rejection: assigning a non-writable / frozen prop. */\n    static void failReadOnly(String name) {\n        throw JsErrorException.typeError(\"Cannot assign to read only property '\" + name + \"'\");\n    }\n\n    /** Strict-mode [[Set]] rejection: adding a key to a non-extensible object. */\n    static void failNotExtensible(String name) {\n        throw JsErrorException.typeError(\"Cannot add property \" + name + \", object is not extensible\");\n    }\n\n    /** Strict-mode [[Delete]] rejection: removing a non-configurable property. */\n    static void failNotConfigurable(String name) {\n        throw JsErrorException.typeError(\"Cannot delete property '\" + name + \"' of \" + \"[object Object]\");\n    }\n\n    @Override\n    public void putMember(String name, Object value) {\n        putMember(name, value, null, false);\n    }\n\n    @Override\n    public void putMember(String name, Object value, CoreContext ctx, boolean strict) {\n        if (\"__proto__\".equals(name)) {\n            if (value instanceof ObjectLike proto) {\n                this.__proto__ = proto;\n            } else if (value == null) {\n                this.__proto__ = null;\n            }\n            return;\n        }\n        // Frozen: ignore all writes (sloppy); strict throws. Non-extensible:","sourceCodeStart":470,"sourceCodeEnd":506,"githubUrl":"https://github.com/karatelabs/karate/blob/a22eb90246d958d15a47bf436693d0121ad2812d/karate-js/src/main/java/io/karatelabs/js/JsObject.java#L470-L506","documentation":"failNotConfigurable implements strict-mode [[Delete]] rejection for string-keyed properties: deleting an existing non-configurable property throws a TypeError, whereas sloppy delete would just return false. The message includes the receiver's toStringTag for context.","triggerScenarios":"Strict-mode delete obj.prop where prop is an own non-configurable property (Object.defineProperty default, frozen/sealed object properties, or built-in slots).","commonSituations":"Deleting properties of a frozen object during cleanup; Object.defineProperty used without configurable:true; sanitizing third-party objects that expose non-configurable fields; strict-mode code where sloppy deletes previously 'succeeded' silently.","solutions":["Avoid deleting; assign undefined (and/or null out the value) instead if configurability can't change","Redefine the property with configurable:true first (possible only if it is currently configurable), then delete","Clone the object minus the key ({[k]: v} rest spread / structuredClone + delete on the copy)"],"exampleFix":"// before\nvar o = Object.freeze({token: 'abc'});\ndelete o.token; // TypeError\n// after\nvar o = {token: 'abc'};\nvar {token, ...rest} = o; // non-mutating removal","handlingStrategy":"try-catch","validationCode":"var d = Object.getOwnPropertyDescriptor(o, name); if (d && !d.configurable) throw new TypeError('prop not configurable: ' + name);","typeGuard":"function isConfigurableProp(o, name) { var d = Object.getOwnPropertyDescriptor(o, name); return !d || d.configurable === true; }","tryCatchPattern":"try { delete o[name]; } catch (e) { if (String(e).includes('Cannot delete property')) { o[name] = undefined; } else { throw e; } }","preventionTips":["Prefer assigning undefined over delete for non-configurable slots","Pass configurable:true in defineProperty for removable fields","Use rest-spread destructuring for non-mutating key removal"],"tags":["javascript","strict-mode","typeerror","delete-operator","frozen-object","karate-js"],"backgroundTag":"delete-non-configurable-property","analyzedSha":"a22eb90246d958d15a47bf436693d0121ad2812d","analyzedAt":"2026-09-12T09:01:00.220Z","contentChangedAt":"2026-09-12T09:01:00.220Z","schemaVersion":2},"datasetVersion":"2026-09-16T19:17:19.609Z"}