{"record":{"id":"752b18b075f41027","repo":"paperclipai/paperclip","slug":"select-a-company-first","errorCode":null,"errorMessage":"Select a company first.","messagePattern":"Select a company first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/src/hooks/useResourceMemberships.ts","lineNumber":154,"sourceCode":"  return Array.isArray(ids) ? ids : [];\n}\n\nexport function useResourceMemberships(companyId: string | null | undefined) {\n  return useQuery({\n    queryKey: queryKeys.resourceMemberships.mine(companyId ?? \"__none__\"),\n    queryFn: () => resourceMembershipsApi.listMine(companyId!),\n    enabled: !!companyId,\n  });\n}\n\nexport function useResourceMembershipMutation(companyId: string | null | undefined) {\n  const queryClient = useQueryClient();\n  const { pushToast } = useToastActions();\n  const queryKey = queryKeys.resourceMemberships.mine(companyId ?? \"__none__\");\n\n  return useMutation({\n    mutationFn: (variables: MutationVariables) => {\n      if (!companyId) throw new Error(\"Select a company first.\");\n      const body = { state: variables.state, starred: variables.starred };\n      return variables.resourceType === \"project\"\n        ? resourceMembershipsApi.updateProject(companyId, variables.resourceId, body)\n        : resourceMembershipsApi.updateAgent(companyId, variables.resourceId, body);\n    },\n    onMutate: async (variables) => {\n      await queryClient.cancelQueries({ queryKey });\n      const previous = queryClient.getQueryData<ResourceMemberships>(queryKey);\n      queryClient.setQueryData<ResourceMemberships>(\n        queryKey,\n        applyMembershipChange(previous, variables.resourceType, variables.resourceId, {\n          state: variables.state,\n          starred: variables.starred,\n        }),\n      );\n      return { previous };\n    },\n    onError: (error, variables, context) => {","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/paperclipai/paperclip/blob/120ae5428fa29bee300bcf806491cd4d965fbb7c/ui/src/hooks/useResourceMemberships.ts#L136-L172","documentation":"UI membership mutation guard: the mutation was triggered while no company is selected (companyId null/undefined). It fails fast instead of sending a request with an undefined company path segment; the surrounding UI should disable membership actions until a company context exists.","triggerScenarios":"Thrown at ui/src/hooks/useResourceMemberships.ts:154 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Select a company from the company picker before managing resource memberships."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"120ae5428fa29bee300bcf806491cd4d965fbb7c","analyzedAt":"2026-08-18T22:49:45.177Z","contentChangedAt":"2026-08-18T22:49:45.177Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}