danny-avila/LibreChat · warning · Error

Conversation ID is required

Error message

Conversation ID is required

What it means

A client-side guard inside the `useMutation` wrapper for `dataService.createSharedLink`. The mutation's variables require a `conversationId`; if it is falsy the mutation throws synchronously before hitting the network, so no API call is made and react-query invokes the mutation's `onError`. It exists to fail fast rather than send an undefined ID to the server.

Source

Thrown at client/src/data-provider/mutations.ts:244

  unknown,
  { conversationId: string; targetMessageId?: string; snapshotFiles?: boolean },
  unknown
> => {
  const queryClient = useQueryClient();

  const { onSuccess, ..._options } = options || {};
  return useMutation(
    ({
      conversationId,
      targetMessageId,
      snapshotFiles,
    }: {
      conversationId: string;
      targetMessageId?: string;
      snapshotFiles?: boolean;
    }) => {
      if (!conversationId) {
        throw new Error('Conversation ID is required');
      }

      return dataService.createSharedLink(conversationId, targetMessageId, snapshotFiles);
    },
    {
      onSuccess: (_data: t.TSharedLinkResponse, vars, context) => {
        syncSharedLinkQueries(queryClient, _data, vars.snapshotFiles);

        onSuccess?.(_data, vars, context);
      },
      ..._options,
    },
  );
};

export const useUpdateSharedLinkMutation = (
  options?: t.MutationOptions<
    t.TUpdateShareLinkRequest,

View on GitHub (pinned to 5ff282f900)

Solutions

  1. Ensure the component calling the mutation has a non-empty `conversationId` — pass it explicitly from the active conversation state.
  2. Disable the share button (or don't mount the mutation caller) while `conversationId` is empty.
  3. If the ID can legitimately be absent, branch before calling `mutate` and surface an inline validation message instead of throwing.

Example fix

// before
const createShareLink = useCreateShareLink();
<Button onClick={() => createShareLink.mutate({ conversationId })} />;
// after — guard the call site so the mutation is never invoked empty
<Button disabled={!conversationId} onClick={() => conversationId && createShareLink.mutate({ conversationId })} />;
Defensive patterns

Strategy: validation

Validate before calling

// Guard the call site
if (!conversationId) throw new Error('Cannot share: no active conversation');
createShareLink.mutate({ conversationId });

Type guard

function hasConversationId(v: unknown): v is { conversationId: string } {
  return typeof v === 'object' && v !== null && typeof (v as any).conversationId === 'string' && (v as any).conversationId.length > 0;
}

Try / catch

// Disable the action at the UI level rather than catching in the mutation
<Button disabled={!conversationId} onClick={() => createShareLink.mutate({ conversationId })} />

Prevention

When it happens

Trigger: A component calls the `createSharedLink` mutation (e.g. the share dialog) before the active conversation ID is known — e.g. rendered during the brief window where `conversationId` is still `undefined`, or wired to a button whose `conversationId` prop was not passed from the parent.

Common situations: Share button rendered in a context without a selected conversation; a refactor that renamed/dropped the `conversationId` prop; opening the share modal from a route that doesn't carry the conversation id; race where the modal mounts before the conversation loads.

Related errors


AI-assisted analysis of danny-avila/LibreChat@5ff282f900 (2026-08-12). Data as JSON: /api/errors/7d2b611da1f4ff47. Report an issue: GitHub.