{"record":{"id":"81f55c9d1b71b5f1","repo":"appsmithorg/appsmith","slug":"eventname-should-be-a-string-81f55c","errorCode":null,"errorMessage":"eventName should be a string","messagePattern":"eventName should be a string","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/client/src/widgets/wds/WDSCustomWidget/component/customWidgetscript.js","lineNumber":252,"sourceCode":"            }\n          };\n        },\n        updateModel: (obj) => {\n          if (!obj || typeof obj !== \"object\") {\n            throw new Error(\"updateModel expects an object as parameter\");\n          }\n\n          appsmith.model = Object.assign(\n            Object.assign({}, appsmith.model),\n            obj,\n          );\n\n          // Send an update model message to the parent\n          channel.postMessage(EVENTS.CUSTOM_WIDGET_UPDATE_MODEL, obj);\n        },\n        triggerEvent: (eventName, contextObj) => {\n          if (typeof eventName !== \"string\") {\n            throw new Error(\"eventName should be a string\");\n          } else if (contextObj && typeof contextObj !== \"object\") {\n            throw new Error(\"contextObj should be an object\");\n          }\n\n          // Send a trigger event message to the parent\n          channel.postMessage(EVENTS.CUSTOM_WIDGET_TRIGGER_EVENT, {\n            eventName,\n            contextObj,\n          });\n        },\n        model: {},\n        onReady: (fn) => {\n          if (typeof fn !== \"function\") {\n            throw new Error(\"onReady expects a function as parameter\");\n          }\n\n          onReady = fn;\n","sourceCodeStart":234,"sourceCodeEnd":270,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/client/src/widgets/wds/WDSCustomWidget/component/customWidgetscript.js#L234-L270","documentation":"Thrown by window.appsmith.triggerEvent() in the WDS Custom Widget iframe. eventName must be a string because it becomes the event key in the CUSTOM_WIDGET_TRIGGER_EVENT payload sent to the parent app. The WDS variant uses the same triggerEvent contract as the legacy widget.","triggerScenarios":"Calling appsmith.triggerEvent(undefined), appsmith.triggerEvent(123), appsmith.triggerEvent({type:'select'}), or appsmith.triggerEvent() with no first argument in the WDS widget.","commonSituations":"Forwarding a numeric event code; passing an event object instead of its string type field; referencing an event-name constant that was not exported from the shared module.","solutions":["Pass a string literal event name: appsmith.triggerEvent('onRowSelect').","Coerce known-safe identifiers: appsmith.triggerEvent(String(e.type)).","Centralize event names in a const map and reference only those.","Ensure a matching event handler is bound on the WDS Custom Widget in the Appsmith app."],"exampleFix":"// before\nappsmith.triggerEvent(event); // event is an object\n\n// after\nappsmith.triggerEvent(event.name, event.detail);","handlingStrategy":"validation","validationCode":"if (typeof eventName !== 'string' || eventName.length === 0) {\n  throw new TypeError('triggerEvent eventName must be a non-empty string');\n}\nappsmith.triggerEvent(eventName, detail);","typeGuard":"const isEventName = (v) => typeof v === 'string' && v.trim().length > 0;\n\n// usage\nif (isEventName(name)) appsmith.triggerEvent(name, detail);","tryCatchPattern":"try {\n  appsmith.triggerEvent(String(name), detail);\n} catch (e) {\n  console.error('triggerEvent rejected name:', e.message);\n}","preventionTips":["Centralize event names in a const map; reference only those keys.","Bind a matching event handler on the WDS Custom Widget.","Coerce only known-safe identifiers with String(); never raw user input.","Ensure the shared event-name module is actually imported in the iframe script."],"tags":["custom-widget","wds","appsmith-api","parameter-validation","javascript"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}