{"record":{"id":"8524f928ed76afdd","repo":"BornToBeRoot/NETworkManager","slug":"group-newprofile-group-not-found-for-new-profile-after","errorCode":null,"errorMessage":"Group '{newProfile.Group}' not found for new profile after creation attempt.","messagePattern":"Group '(.+?)' not found for new profile after creation attempt\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"Source/NETworkManager.Profiles/ProfileManager.cs","lineNumber":1311,"sourceCode":"        ArgumentException.ThrowIfNullOrWhiteSpace(oldProfile.Group, nameof(oldProfile));\n        ArgumentException.ThrowIfNullOrWhiteSpace(newProfile.Group, nameof(newProfile));\n\n        // Remove from old group\n        var oldGroup = LoadedProfileFileData.Groups.FirstOrDefault(x => x.Name.Equals(oldProfile.Group));\n\n        if (oldGroup == null)\n            throw new InvalidOperationException($\"Group '{oldProfile.Group}' not found for old profile.\");\n\n        oldGroup.Profiles.Remove(oldProfile);\n\n        // Add to new group (create if doesn't exist)\n        if (!GroupExists(newProfile.Group))\n            AddGroup(new GroupInfo(newProfile.Group));\n\n        var newGroup = LoadedProfileFileData.Groups.FirstOrDefault(x => x.Name.Equals(newProfile.Group));\n\n        if (newGroup == null)\n            throw new InvalidOperationException($\"Group '{newProfile.Group}' not found for new profile after creation attempt.\");\n\n        newGroup.Profiles.Add(newProfile);\n\n        ProfilesUpdated();\n    }\n\n    /// <summary>\n    ///     Method to remove a profile from a group.\n    /// </summary>\n    /// <param name=\"profile\">Profile as <see cref=\"ProfileInfo\" /> to remove.</param>\n    /// <exception cref=\"ArgumentNullException\">Thrown when profile is null.</exception>\n    /// <exception cref=\"ArgumentException\">Thrown when profile.Group is null or empty.</exception>\n    /// <exception cref=\"InvalidOperationException\">Thrown when profile's group is not found.</exception>\n    public static void RemoveProfile(ProfileInfo profile)\n    {\n        ArgumentNullException.ThrowIfNull(profile);\n        ArgumentException.ThrowIfNullOrWhiteSpace(profile.Group, nameof(profile));\n","sourceCodeStart":1293,"sourceCodeEnd":1329,"githubUrl":"https://github.com/BornToBeRoot/NETworkManager/blob/2780d65469917a296dbc15f206107d72e2d0115c/Source/NETworkManager.Profiles/ProfileManager.cs#L1293-L1329","documentation":"ReplaceProfile successfully removed the old profile from its group, then attempted to create the new profile's target group if missing; the final lookup of newProfile.Group still returned null. The file is now in a partially updated state (old profile removed) and the error reports that the move destination could not be established, so the replacement is aborted with an explicit InvalidOperationException.","triggerScenarios":"Thrown at Source/NETworkManager.Profiles/ProfileManager.cs:1311 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify newProfile.Group names an existing or creatable group (non-empty, trimmed, unique).","Call GroupExists(newProfile.Group) beforehand and create the group via AddGroup if needed.","Do not change newProfile.Group after constructing the profile and before calling ReplaceProfile.","If the error occurs after a partial update, re-load the profile file to restore a consistent state and retry."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2780d65469917a296dbc15f206107d72e2d0115c","analyzedAt":"2026-09-12T17:00:17.986Z","contentChangedAt":"2026-09-12T17:00:17.986Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}