RocketChat/Rocket.Chat · error · Error

Failed to get categories

Error message

Failed to get categories

What it means

Thrown by AppClientOrchestrator.getCategories when GET /apps/categories does not return an Array. The method uses Array.isArray(result) as the structural guard because the typing is loose; a non-array (object envelope, error body, null) is treated as an invalid response.

Source

Thrown at apps/meteor/client/apps/orchestrator.ts:179

			appVersion,
			action,
		});

		if ('url' in result) {
			return result;
		}

		throw new Error('Failed to build external url');
	}

	public async getCategories(): Promise<Serialized<ICategory[]>> {
		const result = await sdk.rest.get('/apps/categories');

		if (Array.isArray(result)) {
			// TODO: chapter day: multiple results are returned, but we only need one
			return result as Serialized<ICategory>[];
		}
		throw new Error('Failed to get categories');
	}
}

export const AppClientOrchestratorInstance = new AppClientOrchestrator();

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Inspect the raw /apps/categories response body to see whether it is wrapped or an error.
  2. Ensure the marketplace is enabled and reachable.
  3. If the server wraps results in an envelope, update the rest-typings and the guard accordingly (e.g. check 'categories' in result).
  4. Confirm server/client version compatibility.
Defensive patterns

Strategy: type-guard

Type guard

function isCategoryArray(r: unknown): r is ICategory[] {
  return Array.isArray(r);
}

Try / catch

try {
  const cats = await orchestrator.getCategories();
} catch (e) {
  if ((e as Error).message === 'Failed to get categories') {
    // inspect raw /apps/categories body; may be wrapped envelope
  }
}

Prevention

When it happens

Trigger: The categories endpoint returns an object envelope (e.g. { categories: [...] }) instead of a bare array, an error object with HTTP 200, null, or the marketplace is disabled so the route returns a different body.

Common situations: Marketplace disabled; server version returning a wrapped envelope; proxy error page; the categories list is empty but wrapped in an object; apps-engine microservice migration changing the shape.

Related errors


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