BornToBeRoot/NETworkManager · error · InvalidOperationException
Group ' ' not found for new profile after creation attempt.
Error message
Group '{newProfile.Group}' not found for new profile after creation attempt. What it means
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.
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.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at Source/NETworkManager.Profiles/ProfileManager.cs:1311 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of BornToBeRoot/NETworkManager@2780d65469 (2026-09-12).
Data as JSON: /api/errors/8524f928ed76afdd.
Report an issue: GitHub.
Appendix: source
Thrown at Source/NETworkManager.Profiles/ProfileManager.cs:1311
ArgumentException.ThrowIfNullOrWhiteSpace(oldProfile.Group, nameof(oldProfile));
ArgumentException.ThrowIfNullOrWhiteSpace(newProfile.Group, nameof(newProfile));
// Remove from old group
var oldGroup = LoadedProfileFileData.Groups.FirstOrDefault(x => x.Name.Equals(oldProfile.Group));
if (oldGroup == null)
throw new InvalidOperationException($"Group '{oldProfile.Group}' not found for old profile.");
oldGroup.Profiles.Remove(oldProfile);
// Add to new group (create if doesn't exist)
if (!GroupExists(newProfile.Group))
AddGroup(new GroupInfo(newProfile.Group));
var newGroup = LoadedProfileFileData.Groups.FirstOrDefault(x => x.Name.Equals(newProfile.Group));
if (newGroup == null)
throw new InvalidOperationException($"Group '{newProfile.Group}' not found for new profile after creation attempt.");
newGroup.Profiles.Add(newProfile);
ProfilesUpdated();
}
/// <summary>
/// Method to remove a profile from a group.
/// </summary>
/// <param name="profile">Profile as <see cref="ProfileInfo" /> to remove.</param>
/// <exception cref="ArgumentNullException">Thrown when profile is null.</exception>
/// <exception cref="ArgumentException">Thrown when profile.Group is null or empty.</exception>
/// <exception cref="InvalidOperationException">Thrown when profile's group is not found.</exception>
public static void RemoveProfile(ProfileInfo profile)
{
ArgumentNullException.ThrowIfNull(profile);
ArgumentException.ThrowIfNullOrWhiteSpace(profile.Group, nameof(profile));
View on GitHub (pinned to 2780d65469)