{"record":{"id":"dd6ff4f723d75d50","repo":"pentaho/pentaho-kettle","slug":"typeidoralias","errorCode":null,"errorMessage":"typeIdOrAlias","messagePattern":"typeIdOrAlias","errorType":"validation","errorClass":"ArgumentRequiredError","httpStatus":null,"severity":"error","filePath":"plugins/core-ui/src/main/resources/app/pentaho/_core/module/InstanceMeta.js","lineNumber":58,"sourceCode":"       * @param {pentaho.module.spec.IInstanceMeta} spec - The specification of the metadata of the instance module.\n       * @param {pentaho._core.module.Resolver} resolver - The module resolver function.\n       */\n      constructor: function(id, spec, resolver) {\n\n        this.base(id, spec, resolver);\n\n        var type = spec.type || null;\n\n        this.type = type && resolver(type, \"type\");\n        if(type) {\n          this.type.__addInstance(this);\n        }\n      },\n\n      /** @inheritDoc  */\n      isInstanceOf: function(typeIdOrAlias) {\n        if(!typeIdOrAlias) {\n          throw new ArgumentRequiredError(\"typeIdOrAlias\");\n        }\n\n        return this.type !== null && this.type.isSubtypeOf(typeIdOrAlias);\n      },\n\n      /** @override */\n      _prepareCoreAsync: function() {\n\n        if(this.type !== null) {\n          return this.type.prepareAsync().then(this.base.bind(this));\n        }\n\n        return this.base();\n      }\n    });\n  };\n});\n","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/core-ui/src/main/resources/app/pentaho/_core/module/InstanceMeta.js#L40-L76","documentation":"InstanceMeta.isInstanceOf(typeIdOrAlias) checks whether the instance's type is a subtype of the given type ID or alias. If typeIdOrAlias is falsy (null, undefined, empty string), it throws ArgumentRequiredError(\"typeIdOrAlias\") instead of returning false. Callers must supply a non-empty type identifier.","triggerScenarios":"Calling instance.isInstanceOf(x) where x comes from an unresolved variable, an empty config value, a failed type resolution, or a function parameter not passed by the caller.","commonSituations":"Type metadata loaded asynchronously and the ID variable not yet set; refactoring where a typeId constant was removed; chaining code like isInstanceOf(typeOf(thing)) where typeOf returns undefined for unknown objects; empty string from a split/lookup by key.","solutions":["Pass a valid non-empty type ID or alias, e.g. instance.isInstanceOf('pentaho/type/string').","Add a guard at the call site: only call isInstanceOf when the ID is known (if (typeId) ...).","Trace why the variable holding the type ID is empty (resolution order, async load) and fix upstream.","If the intent was 'is it of any type', use an explicit check against the base type or restructure the logic rather than passing null."],"exampleFix":"// before\nvar typeId = getTypeFromConfig(); // may be undefined\nif (instance.isInstanceOf(typeId)) { ... }\n// after\nvar typeId = getTypeFromConfig();\nif (typeId && instance.isInstanceOf(typeId)) { ... }","handlingStrategy":"type-guard","validationCode":"if (typeof typeIdOrAlias !== \"string\" || typeIdOrAlias.length === 0) {\n  throw new Error(\"typeIdOrAlias must be a non-empty string\");\n}","typeGuard":"function isValidTypeId(typeIdOrAlias) {\n  return typeof typeIdOrAlias === \"string\" && typeIdOrAlias.trim().length > 0;\n}","tryCatchPattern":"try {\n  result = instance.isInstanceOf(typeId);\n} catch (ex) {\n  if (ex.name === \"ArgumentRequiredError\" && ex.message === \"typeIdOrAlias\") {\n    logger.warn(\"isInstanceOf called with empty type ID; treating as false\");\n    result = false;\n  } else { throw ex; }\n}","preventionTips":["Guard callers so isInstanceOf is only invoked with a resolved, non-empty type ID.","Never pass the result of an unresolved type lookup straight into isInstanceOf.","Prefer explicit constants for type IDs over dynamically derived values.","Handle async type-metadata loading before running subtype checks."],"tags":["javascript","validation","arguments","pentaho"],"backgroundTag":"missing-required-argument","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}