RocketChat/Rocket.Chat · error · Error

Invalid type

Error message

Invalid type

What it means

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'.

Source

Thrown at apps/meteor/ee/server/api/v1/omnichannel/lib/outbound.ts:31

export class OutboundMessageProviderService implements IOutboundMessageProviderService {
	private readonly provider: OutboundMessageProvider;

	constructor() {
		this.provider = new OutboundMessageProvider();
	}

	get outboundMessageProvider() {
		return this.provider;
	}

	private isProviderValid(type: any): type is ValidOutboundProvider {
		return ValidOutboundProviderList.includes(type);
	}

	public listOutboundProviders(type?: string): IOutboundProvider[] {
		if (type !== undefined && !this.isProviderValid(type)) {
			throw new Error('Invalid type');
		}

		return this.provider.getOutboundMessageProviders(type);
	}

	public getProviderMetadata(providerId: string): Promise<IOutboundProviderMetadata> {
		const provider = this.provider.findOneByProviderId(providerId);
		if (!provider) {
			throw new Error('error-invalid-provider');
		}

		return this.getProviderManager().getProviderMetadata(provider.appId, provider.type);
	}

	private getProviderManager() {
		if (!Apps.self?.isLoaded()) {
			throw new Error('apps-engine-not-loaded');
		}

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Omit the type argument to list all providers, or pass only a value from ValidOutboundProviderList.
  2. Validate the type against ValidOutboundProviderList before calling.
  3. Update the caller's hardcoded type list to match the installed @rocket.chat/core-typings version.
  4. Expose the valid list to the UI so users pick from supported values.

Example fix

// before: unvalidated input
const providers = svc.listOutboundProviders(req.query.type);

// after: validate against the allow-list
import { ValidOutboundProviderList } from '@rocket.chat/core-typings';
const type = req.query.type;
if (type !== undefined && !ValidOutboundProviderList.includes(type)) {
  throw new BadRequestError(`Invalid type; expected one of ${ValidOutboundProviderList.join(', ')}`);
}
const providers = svc.listOutboundProviders(type);
Defensive patterns

Strategy: type-guard

Validate before calling

// Validate the type before calling
import { ValidOutboundProviderList } from '@rocket.chat/core-typings';
function assertOutboundType(type: string | undefined) {
  if (type !== undefined && !ValidOutboundProviderList.includes(type as any)) {
    throw new Error(`Invalid type; expected one of ${ValidOutboundProviderList.join(', ')}`);
  }
}
assertOutboundType(type);
svc.listOutboundProviders(type);

Type guard

import { ValidOutboundProviderList, type ValidOutboundProvider } from '@rocket.chat/core-typings';
function isValidOutboundProvider(type: unknown): type is ValidOutboundProvider {
  return typeof type === 'string' && (ValidOutboundProviderList as readonly string[]).includes(type);
}

Try / catch

try {
  return svc.listOutboundProviders(type);
} catch (e) {
  if (e.message === 'Invalid type') {
    // fall back to listing all providers
    return svc.listOutboundProviders();
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: Hardcoded provider type string out of date after an upgrade; copy-paste from docs of a different version; user input passed through without validation.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@f9d3ec372b (2026-08-12). Data as JSON: /api/errors/7609c64feab2cb06. Report an issue: GitHub.