{"record":{"id":"7609c64feab2cb06","repo":"RocketChat/Rocket.Chat","slug":"invalid-type","errorCode":null,"errorMessage":"Invalid type","messagePattern":"Invalid type","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/ee/server/api/v1/omnichannel/lib/outbound.ts","lineNumber":31,"sourceCode":"\nexport class OutboundMessageProviderService implements IOutboundMessageProviderService {\n\tprivate readonly provider: OutboundMessageProvider;\n\n\tconstructor() {\n\t\tthis.provider = new OutboundMessageProvider();\n\t}\n\n\tget outboundMessageProvider() {\n\t\treturn this.provider;\n\t}\n\n\tprivate isProviderValid(type: any): type is ValidOutboundProvider {\n\t\treturn ValidOutboundProviderList.includes(type);\n\t}\n\n\tpublic listOutboundProviders(type?: string): IOutboundProvider[] {\n\t\tif (type !== undefined && !this.isProviderValid(type)) {\n\t\t\tthrow new Error('Invalid type');\n\t\t}\n\n\t\treturn this.provider.getOutboundMessageProviders(type);\n\t}\n\n\tpublic getProviderMetadata(providerId: string): Promise<IOutboundProviderMetadata> {\n\t\tconst provider = this.provider.findOneByProviderId(providerId);\n\t\tif (!provider) {\n\t\t\tthrow new Error('error-invalid-provider');\n\t\t}\n\n\t\treturn this.getProviderManager().getProviderMetadata(provider.appId, provider.type);\n\t}\n\n\tprivate getProviderManager() {\n\t\tif (!Apps.self?.isLoaded()) {\n\t\t\tthrow new Error('apps-engine-not-loaded');\n\t\t}","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/f9d3ec372bb580fa8d036f94cf03925a478ef768/apps/meteor/ee/server/api/v1/omnichannel/lib/outbound.ts#L13-L49","documentation":"Thrown by OutboundMessageProviderService.listOutboundProviders when an optional type argument is supplied that is not in ValidOutboundProviderList. The type must be one of the supported outbound provider types; any other string is rejected before the provider lookup runs. Plain Error, message 'Invalid type'.","triggerScenarios":"Calling listOutboundProviders('foo') where 'foo' is not a ValidOutboundProvider. Typo in the provider type, passing an internal code name that is not yet registered, or sending a value from a newer/older API version.","commonSituations":"Hardcoded provider type string out of date after an upgrade; copy-paste from docs of a different version; user input passed through without validation.","solutions":["Omit the type argument to list all providers, or pass only a value from ValidOutboundProviderList.","Validate the type against ValidOutboundProviderList before calling.","Update the caller's hardcoded type list to match the installed @rocket.chat/core-typings version.","Expose the valid list to the UI so users pick from supported values."],"exampleFix":"// before: unvalidated input\nconst providers = svc.listOutboundProviders(req.query.type);\n\n// after: validate against the allow-list\nimport { ValidOutboundProviderList } from '@rocket.chat/core-typings';\nconst type = req.query.type;\nif (type !== undefined && !ValidOutboundProviderList.includes(type)) {\n  throw new BadRequestError(`Invalid type; expected one of ${ValidOutboundProviderList.join(', ')}`);\n}\nconst providers = svc.listOutboundProviders(type);","handlingStrategy":"type-guard","validationCode":"// Validate the type before calling\nimport { ValidOutboundProviderList } from '@rocket.chat/core-typings';\nfunction assertOutboundType(type: string | undefined) {\n  if (type !== undefined && !ValidOutboundProviderList.includes(type as any)) {\n    throw new Error(`Invalid type; expected one of ${ValidOutboundProviderList.join(', ')}`);\n  }\n}\nassertOutboundType(type);\nsvc.listOutboundProviders(type);","typeGuard":"import { ValidOutboundProviderList, type ValidOutboundProvider } from '@rocket.chat/core-typings';\nfunction isValidOutboundProvider(type: unknown): type is ValidOutboundProvider {\n  return typeof type === 'string' && (ValidOutboundProviderList as readonly string[]).includes(type);\n}","tryCatchPattern":"try {\n  return svc.listOutboundProviders(type);\n} catch (e) {\n  if (e.message === 'Invalid type') {\n    // fall back to listing all providers\n    return svc.listOutboundProviders();\n  }\n  throw e;\n}","preventionTips":["Drive type selection in the UI from ValidOutboundProviderList so users cannot pick unsupported values.","Keep the allow-list in sync with the installed @rocket.chat/core-typings version."],"tags":["omnichannel","outbound","apps-engine","validation"],"backgroundTag":null,"analyzedSha":"f9d3ec372bb580fa8d036f94cf03925a478ef768","analyzedAt":"2026-08-12T19:07:17.372Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}