{"record":{"id":"7d2b611da1f4ff47","repo":"danny-avila/LibreChat","slug":"conversation-id-is-required","errorCode":null,"errorMessage":"Conversation ID is required","messagePattern":"Conversation ID is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"client/src/data-provider/mutations.ts","lineNumber":244,"sourceCode":"  unknown,\n  { conversationId: string; targetMessageId?: string; snapshotFiles?: boolean },\n  unknown\n> => {\n  const queryClient = useQueryClient();\n\n  const { onSuccess, ..._options } = options || {};\n  return useMutation(\n    ({\n      conversationId,\n      targetMessageId,\n      snapshotFiles,\n    }: {\n      conversationId: string;\n      targetMessageId?: string;\n      snapshotFiles?: boolean;\n    }) => {\n      if (!conversationId) {\n        throw new Error('Conversation ID is required');\n      }\n\n      return dataService.createSharedLink(conversationId, targetMessageId, snapshotFiles);\n    },\n    {\n      onSuccess: (_data: t.TSharedLinkResponse, vars, context) => {\n        syncSharedLinkQueries(queryClient, _data, vars.snapshotFiles);\n\n        onSuccess?.(_data, vars, context);\n      },\n      ..._options,\n    },\n  );\n};\n\nexport const useUpdateSharedLinkMutation = (\n  options?: t.MutationOptions<\n    t.TUpdateShareLinkRequest,","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/client/src/data-provider/mutations.ts#L226-L262","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure the component calling the mutation has a non-empty `conversationId` — pass it explicitly from the active conversation state.","Disable the share button (or don't mount the mutation caller) while `conversationId` is empty.","If the ID can legitimately be absent, branch before calling `mutate` and surface an inline validation message instead of throwing."],"exampleFix":"// before\nconst createShareLink = useCreateShareLink();\n<Button onClick={() => createShareLink.mutate({ conversationId })} />;\n// after — guard the call site so the mutation is never invoked empty\n<Button disabled={!conversationId} onClick={() => conversationId && createShareLink.mutate({ conversationId })} />;","handlingStrategy":"validation","validationCode":"// Guard the call site\nif (!conversationId) throw new Error('Cannot share: no active conversation');\ncreateShareLink.mutate({ conversationId });","typeGuard":"function hasConversationId(v: unknown): v is { conversationId: string } {\n  return typeof v === 'object' && v !== null && typeof (v as any).conversationId === 'string' && (v as any).conversationId.length > 0;\n}","tryCatchPattern":"// Disable the action at the UI level rather than catching in the mutation\n<Button disabled={!conversationId} onClick={() => createShareLink.mutate({ conversationId })} />","preventionTips":["Pass conversationId explicitly from active conversation state to the share dialog.","Disable the share button until a conversation is selected.","Type the mutation variables so TypeScript flags missing conversationId at compile time."],"tags":["react","react-query","validation","share","client"],"backgroundTag":null,"analyzedSha":"5ff282f9006c436e561de1afd39a481bea1ef0d8","analyzedAt":"2026-08-12T21:38:08.145Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}