RocketChat/Rocket.Chat · error · Meteor.Error

invalid-store

invalid-store

Error message

Store not found

What it means

ufsComplete looks up the named UploadFS store via UploadFS.getStore(storeName); an unknown name returns undefined and the method throws Meteor.Error 'invalid-store' ('Store not found'). Stores are registered on the server at startup (e.g. Uploads, UserDataFiles, avatars); the name must match exactly what was registered.

Source

Thrown at apps/meteor/server/ufs/ufs-methods.ts:17

import fs from 'node:fs';

import type { IUpload } from '@rocket.chat/core-typings';
import { check } from 'meteor/check';
import { Meteor } from 'meteor/meteor';
import type { ClientSession } from 'mongodb';

import { UploadFS } from './ufs';

export async function ufsComplete(fileId: string, storeName: string, options?: { session?: ClientSession }): Promise<IUpload> {
	check(fileId, String);
	check(storeName, String);

	// Get store
	const store = UploadFS.getStore(storeName);
	if (!store) {
		throw new Meteor.Error('invalid-store', 'Store not found');
	}

	const tmpFile = UploadFS.getTempFilePath(fileId);

	const removeTempFile = () =>
		fs.promises.unlink(tmpFile).catch(() => {
			console.warn(`[ufsComplete] Failed to remove temp file: ${tmpFile}`);
		});

	return new Promise(async (resolve, reject) => {
		try {
			// todo check if temp file exists

			// Get file
			const file = await store.getCollection().findOne<IUpload>({ _id: fileId }, { session: options?.session });

			if (!file) {
				throw new Meteor.Error('invalid-file', 'File is not valid');

View on GitHub (pinned to b2c16d5842)

Solutions

  1. Match the store name exactly to the registered store (check where UploadFS stores are defined/registered server-side).
  2. Ensure ufsComplete runs on the process where the store is registered (single Meteor app process or correct service).
  3. List registered stores at runtime (UploadFS stores map) during debugging to see the valid names.

Example fix

// before
await Meteor.callAsync('ufsComplete', fileId, 'upload');

// after
await Meteor.callAsync('ufsComplete', fileId, 'Uploads'); // exact registered store name
Defensive patterns

Strategy: validation

Validate before calling

import { UploadFS } from '../ufs';
const store = UploadFS.getStore(storeName);
if (!store) {
  throw new Error(`Valid stores: ${Object.keys(UploadFS.stores).join(', ')}`);
}

Type guard

const isValidStore = (name: string): boolean =>
  Boolean(UploadFS.getStore(name));

Try / catch

try { await ufsComplete(fileId, storeName); } catch (e) { if (isMeteorError(e, 'invalid-store')) { /* fix storeName against registered stores */ return; } throw e; }

Prevention

When it happens

Trigger: Calling ufsComplete(fileId, storeName) with a misspelled or unregistered store name, calling before server startup registered the stores, or invoking ufsComplete against a server process that does not own/register that store.

Common situations: Custom upload clients passing 'upload' instead of 'Uploads'; split-process deployments where the method runs where the store is not registered; typos in integrations using the UFS legacy API.

Related errors


AI-assisted analysis of RocketChat/Rocket.Chat@b2c16d5842 (2026-08-18). Data as JSON: /api/errors/911d7e27de534d7f. Report an issue: GitHub.