{"record":{"id":"f58741da3db9bb45","repo":"immich-app/immich","slug":"partner-not-found","errorCode":null,"errorMessage":"Partner not found","messagePattern":"Partner not found","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"server/src/services/partner.service.ts","lineNumber":33,"sourceCode":"    if (exists) {\n      throw new BadRequestException(`Partner already exists`);\n    }\n\n    const user = await this.userRepository.get(sharedWithId, {});\n    if (!user) {\n      this.logger.debug('Partner creation failed: user not found');\n      throw new BadRequestException('Invalid user');\n    }\n\n    const partner = await this.partnerRepository.create(partnerId);\n    return this.mapPartner(partner, PartnerDirection.SharedBy);\n  }\n\n  async remove(auth: AuthDto, sharedWithId: string): Promise<void> {\n    const partnerId: PartnerIds = { sharedById: auth.user.id, sharedWithId };\n    const partner = await this.partnerRepository.get(partnerId);\n    if (!partner) {\n      throw new BadRequestException('Partner not found');\n    }\n\n    await this.partnerRepository.remove(partnerId);\n  }\n\n  async search(auth: AuthDto, { direction }: PartnerSearchDto): Promise<PartnerResponseDto[]> {\n    const partners = await this.partnerRepository.getAll(auth.user.id);\n    const key = direction === PartnerDirection.SharedBy ? 'sharedById' : 'sharedWithId';\n    return partners\n      .filter((partner): partner is Partner => !!(partner.sharedBy && partner.sharedWith)) // Filter out soft deleted users\n      .filter((partner) => partner[key] === auth.user.id)\n      .map((partner) => this.mapPartner(partner, direction));\n  }\n\n  async update(auth: AuthDto, sharedById: string, dto: PartnerUpdateDto): Promise<PartnerResponseDto> {\n    await this.requireAccess({ auth, permission: Permission.PartnerUpdate, ids: [sharedById] });\n    const partnerId: PartnerIds = { sharedById, sharedWithId: auth.user.id };\n","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/immich-app/immich/blob/e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c/server/src/services/partner.service.ts#L15-L51","documentation":"PartnerService.remove looks up the partner record for the ordered pair (sharedById=caller, sharedWithId) and throws BadRequestException('Partner not found') when no such relation exists. Deletion is only allowed for a partnership that the caller established in this direction.","triggerScenarios":"DELETE /api/partners/{sharedWithId} where the calling user has no partner record with that user as sharedWithId — wrong ID, already removed, or the partnership was created in the opposite direction.","commonSituations":"Retrying a delete after it already succeeded, stale UI listing, deleting a partner who added you (they own that record), or wrong user ID after a migration.","solutions":["Refresh the partner list (GET /api/partners) and delete using a current partner ID.","Note the direction: you can only remove partners you added; partners who added you are removed from their side or via the appropriate direction parameter.","Treat 400 'Partner not found' as an idempotent success in retry logic.","Verify the sharedWithId matches the user you intend to unshare with."],"exampleFix":"// before\nawait api.partnersApi.removePartner({ id: partnerUserId }); // throws if already gone\n// after\ntry {\n  await api.partnersApi.removePartner({ id: partnerUserId });\n} catch (e) {\n  if (!String(e).includes('Partner not found')) throw e; // already removed — ignore\n}","handlingStrategy":"try-catch","validationCode":"const mine = await api.partnersApi.getPartners({ direction: 'shared-by' });\nif (!mine.some((p) => p.userId === sharedWithId)) return; // nothing to remove","typeGuard":null,"tryCatchPattern":"try {\n  await api.partnersApi.removePartner({ id: sharedWithId });\n} catch (e) {\n  if (e.status === 400 && String(e.message).includes('Partner not found')) return; // already removed\n  throw e;\n}","preventionTips":["Refresh the partner list before rendering delete actions.","Treat removal as idempotent — ignore 400 'Partner not found'.","Remember only partners you added (shared-by direction) can be removed by you."],"tags":["partner","not-found","delete","bad-request"],"backgroundTag":"record-not-found","analyzedSha":"e55ac299a4ec7cb372e35dbf2c6c05ee9ce77f6c","analyzedAt":"2026-09-15T07:20:19.675Z","contentChangedAt":"2026-09-15T07:20:19.675Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}