RocketChat/Rocket.Chat · error · Meteor.Error

error-updating-custom-user-status

error-updating-custom-user-status

Error message

Error updating custom user status

What it means

Thrown by POST custom-user-status.update after insertOrUpdateUserStatus completed but CustomUserStatus.findOneById(_id) returns null. The record disappeared between the update and the re-fetch. Note the earlier 'no custom user status found' case is returned as API.v1.failure, whereas this post-update miss throws — so the throw specifically signals a race or vanishing record mid-request.

Source

Thrown at apps/meteor/server/api/v1/custom-user-status.ts:269

		const userStatusData = {
			_id: this.bodyParams._id,
			name: this.bodyParams.name,
			statusType: this.bodyParams.statusType || '',
		};

		const customUserStatusToUpdate = await CustomUserStatus.findOneById(userStatusData._id);

		// Ensure the message exists
		if (!customUserStatusToUpdate) {
			return API.v1.failure(`No custom user status found with the id of "${userStatusData._id}".`);
		}

		await insertOrUpdateUserStatus(this.userId, userStatusData);

		const customUserStatus = await CustomUserStatus.findOneById(userStatusData._id);

		if (!customUserStatus) {
			throw new Meteor.Error('error-updating-custom-user-status', 'Error updating custom user status');
		}

		return API.v1.success({
			customUserStatus,
		});
	},
);

export type CustomUserStatusEndpoints = ExtractRoutesFromAPI<typeof customUserStatusEndpoints>;

declare module '@rocket.chat/rest-typings' {
	// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
	interface Endpoints extends CustomUserStatusEndpoints {}
}

View on GitHub (pinned to f9d3ec372b)

Solutions

  1. Retry the update after confirming the status still exists.
  2. Guard against concurrent deletes (lock the UI row while editing).
  3. Reload the status list to obtain a fresh _id before re-submitting.
Defensive patterns

Strategy: retry

Validate before calling

// confirm the row still exists right before updating
const current = await CustomUserStatus.findOneById(_id);
if (!current) { /* abort update */ }

Try / catch

try { await updateCustomUserStatus({ _id, name, statusType }); }
catch (e) {
  if (isApiError(e, 'error-updating-custom-user-status')) { /* reload list, retry once */) }
  else throw e;
}

Prevention

When it happens

Trigger: Another admin/process deletes the status between the update call and the re-read; _id invalidated mid-flight; insertOrUpdateUserStatus deleted-then-failed.

Common situations: Two admins editing/deleting the same status concurrently; stale _id held by the client.

Related errors


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