{"record":{"id":"020794b4daf42fb3","repo":"Kareadita/Kavita","slug":"profile-does-not-exist","errorCode":null,"errorMessage":"profile-does-not-exist","messagePattern":"profile-does-not-exist","errorType":"exception","errorClass":"KavitaException","httpStatus":500,"severity":"error","filePath":"Kavita.Services/Reading/ReadingProfileService.cs","lineNumber":41,"sourceCode":"    public async Task<AppUserReadingProfile> GetReadingProfileForSeries(int userId, int libraryId, int seriesId,\n        int? activeDeviceId, bool skipImplicit = false)\n    {\n        return await unitOfWork.AppUserReadingProfileRepository.GetProfileForSeries(userId, libraryId, seriesId,\n            activeDeviceId, skipImplicit);\n    }\n\n    public async Task<UserReadingProfileDto> GetReadingProfileDtoForSeries(int userId, int libraryId, int seriesId,\n        int? activeDeviceId, bool skipImplicit = false)\n    {\n        return mapper.Map<UserReadingProfileDto>(await GetReadingProfileForSeries(userId, libraryId, seriesId,\n            activeDeviceId, skipImplicit));\n    }\n\n    public async Task<UserReadingProfileDto> UpdateParent(int userId, int libraryId, int seriesId,\n        UserReadingProfileDto dto, int? activeDeviceId)\n    {\n        var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, dto.Id);\n        if (profile == null) throw new KavitaException(\"profile-does-not-exist\");\n\n        var parentProfile = await GetReadingProfileForSeries(userId, libraryId, seriesId, activeDeviceId, true);\n\n        UpdateReaderProfileFields(parentProfile, dto, false);\n        unitOfWork.AppUserReadingProfileRepository.Update(parentProfile);\n\n        // Delete profile as we'll be using the parent now\n        unitOfWork.AppUserReadingProfileRepository.Remove(profile);\n\n        await unitOfWork.CommitAsync();\n        return mapper.Map<UserReadingProfileDto>(parentProfile);\n    }\n\n    public async Task<UserReadingProfileDto> UpdateReadingProfile(int userId, UserReadingProfileDto dto)\n    {\n        var profile = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, dto.Id);\n        if (profile == null) throw new KavitaException(\"profile-does-not-exist\");\n","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/Kareadita/Kavita/blob/9c3e5400007f8a0282f7d883f2ad5e71716e514d/Kavita.Services/Reading/ReadingProfileService.cs#L23-L59","documentation":"Thrown by UpdateParent when GetUserProfile(userId, dto.Id) returns null — the target reading profile that should be merged into the series' parent profile does not exist for the user. The literal 'profile-does-not-exist' is a localization key surfaced to the UI. UpdateParent deletes the named profile and applies its settings onto the resolved parent profile.","triggerScenarios":"Client sends a profile id (dto.Id) that was already deleted, belongs to another user, or never existed; concurrent profile edits deleted it between load and update.","commonSituations":"UI had a stale profile id after another tab deleted it; profile was reset/cleared; id mismatch after a data migration.","solutions":["Refresh the user's reading profile list and retry with a current profile id.","Verify the profile id belongs to the requesting user and still exists.","Handle the not-found case gracefully in the UI instead of retrying the same stale id."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var exists = await unitOfWork.AppUserReadingProfileRepository.GetUserProfile(userId, dto.Id) is not null;\nif (!exists) return NotFound(\"profile-does-not-exist\");\nawait profileService.UpdateParent(userId, libraryId, seriesId, dto, activeDeviceId);","typeGuard":"public static bool ProfileFound(AppUserReadingProfile? p) => p is not null;","tryCatchPattern":"try { await profileService.UpdateParent(userId, libraryId, seriesId, dto, activeDeviceId); }\ncatch (KavitaException ex) when (ex.Message == \"profile-does-not-exist\") { return NotFound(); }","preventionTips":["Refresh the profile list in the UI before merge/update actions.","Pass only currently-valid profile ids; discard stale references after deletes."],"tags":["reading-profiles","not-found","validation"],"backgroundTag":null,"analyzedSha":"9c3e5400007f8a0282f7d883f2ad5e71716e514d","analyzedAt":"2026-08-13T19:06:05.897Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}