{"record":{"id":"c7ab302233ef9064","repo":"danny-avila/LibreChat","slug":"share-id-is-required","errorCode":null,"errorMessage":"Share ID is required","messagePattern":"Share ID is required","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"client/src/data-provider/mutations.ts","lineNumber":277,"sourceCode":"\nexport const useUpdateSharedLinkMutation = (\n  options?: t.MutationOptions<\n    t.TUpdateShareLinkRequest,\n    t.TUpdateShareLinkRequest & { snapshotFiles?: boolean }\n  >,\n): UseMutationResult<\n  t.TSharedLinkResponse,\n  unknown,\n  t.TUpdateShareLinkRequest & { snapshotFiles?: boolean },\n  unknown\n> => {\n  const queryClient = useQueryClient();\n\n  const { onSuccess, ..._options } = options || {};\n  return useMutation(\n    ({ shareId, targetMessageId, snapshotFiles }) => {\n      if (!shareId) {\n        throw new Error('Share ID is required');\n      }\n      return dataService.updateSharedLink(shareId, 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 useDeleteSharedLinkMutation = (\n  options?: t.DeleteSharedLinkOptions,\n): UseMutationResult<\n  t.TDeleteSharedLinkResponse,","sourceCodeStart":259,"sourceCodeEnd":295,"githubUrl":"https://github.com/danny-avila/LibreChat/blob/5ff282f9006c436e561de1afd39a481bea1ef0d8/client/src/data-provider/mutations.ts#L259-L295","documentation":"Mirror of error 191 for the update path: the `useMutation` wrapping `dataService.updateSharedLink` requires `shareId` and throws synchronously if it is falsy, preventing a malformed PATCH/PUT to the server. The share ID identifies an existing shared link to update.","triggerScenarios":"The update-share mutation is invoked before the share record has been loaded/created — e.g. an \"edit share\" form whose `shareId` prop is still `undefined` because the create call hasn't resolved, or a share-management UI opened without a selected link.","commonSituations":"Editing a shared link whose record hasn't been fetched yet; a list/detail view where no share is selected but the edit handler fired; refactor that dropped the `shareId` binding; calling update before the create mutation's `onSuccess` populated the ID.","solutions":["Ensure `shareId` is populated before enabling the update action — gate it on the share record being loaded.","Render the edit form only after the share link exists (e.g. after `createSharedLink` resolves).","If multiple shares exist, confirm the correct `shareId` is passed from the selected list item."],"exampleFix":"// before\nconst updateShareLink = useUpdateShareLink();\nuseEffect(() => { if (shareId) updateShareLink.mutate({ shareId, ... }); }, [shareId]);\n// after — only mutate once the shareId is known\nuseEffect(() => { if (!shareId) return; updateShareLink.mutate({ shareId, ... }); }, [shareId]);","handlingStrategy":"validation","validationCode":"// Guard the call site\nif (!shareId) throw new Error('Cannot update: no share selected');\nupdateShareLink.mutate({ shareId, ...patch });","typeGuard":"function hasShareId(v: unknown): v is { shareId: string } {\n  return typeof v === 'object' && v !== null && typeof (v as any).shareId === 'string' && (v as any).shareId.length > 0;\n}","tryCatchPattern":"// Gate the edit form on the share existing\nif (!shareId) return;\nupdateShareLink.mutate({ shareId, ...patch });","preventionTips":["Render the edit-share form only after the share record is loaded.","Disable update controls until shareId is known.","Type mutation variables so a missing shareId is a compile error."],"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"}