BornToBeRoot/NETworkManager · error · InvalidOperationException

Group ' ' not found for profile after creation attempt.

Error message

Group '{profile.Group}' not found for profile after creation attempt.

What it means

AddProfile attempted to create the profile's group if it did not exist, but the subsequent lookup of profile.Group in LoadedProfileFileData.Groups still returned null. This indicates AddGroup failed silently or the group name was altered between creation and lookup, so the profile cannot be attached to any group and the invariant 'profile always has an existing group' is broken.

Solutions

  1. Ensure the profile's Group name is non-empty, trimmed, and stable before calling AddProfile.
  2. Verify AddGroup succeeded (no exceptions, group visible via GroupExists) before adding profiles to it.
  3. Avoid mutating the group name on the profile between group creation and profile insertion.
  4. Reload profile data if another thread modified the groups collection concurrently.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at Source/NETworkManager.Profiles/ProfileManager.cs:1245 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/c0810a5e48c855eb. Report an issue: GitHub.

Appendix: source

Thrown at Source/NETworkManager.Profiles/ProfileManager.cs:1245

    /// <summary>
    ///     Method to add a profile to a group.
    /// </summary>
    /// <param name="profile">Profile as <see cref="ProfileInfo" /> to add.</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 after creation attempt.</exception>
    public static void AddProfile(ProfileInfo profile)
    {
        ArgumentNullException.ThrowIfNull(profile);
        ArgumentException.ThrowIfNullOrWhiteSpace(profile.Group, nameof(profile));

        if (!GroupExists(profile.Group))
            AddGroup(new GroupInfo(profile.Group));

        var group = LoadedProfileFileData.Groups.FirstOrDefault(x => x.Name.Equals(profile.Group));

        if (group == null)
            throw new InvalidOperationException($"Group '{profile.Group}' not found for profile after creation attempt.");

        group.Profiles.Add(profile);

        ProfilesUpdated();
    }

    /// <summary>
    ///     Method to add multiple profiles, creating missing groups as needed.
    ///     Fires <see cref="ProfilesUpdated" /> once after all profiles are added.
    /// </summary>
    /// <param name="profiles">Profiles to add.</param>
    /// <exception cref="ArgumentNullException">Thrown when profiles is null.</exception>
    public static void AddProfiles(IEnumerable<ProfileInfo> profiles)
    {
        ArgumentNullException.ThrowIfNull(profiles);

        foreach (var profile in profiles)
        {

View on GitHub (pinned to 2780d65469)