BornToBeRoot/NETworkManager · error · InvalidOperationException

Group ' ' not found after creation attempt.

Error message

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

What it means

AddProfiles creates each missing group via AddGroup(profile.Group) before inserting the profile, but the following FirstOrDefault lookup for the just-created group still found nothing. This is the same post-creation invariant check as AddProfile, applied during bulk import: the batch cannot be applied because a profile's target group is absent from the loaded profile file even after the creation attempt.

Solutions

  1. Validate every profile in the batch has a consistent, non-empty Group value before calling AddProfiles.
  2. Check that AddGroup is not failing or being skipped for duplicate/invalid group names in the batch.
  3. Ensure no concurrent modification of the groups collection during the bulk import.
  4. After an import error, inspect the profile file to see which groups were actually created and retry with corrected group names.
Defensive patterns

Strategy: validation

When it happens

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

Appendix: source

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

    /// </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)
        {
            if (profile is null)
                continue;

            if (!GroupExists(profile.Group))
                AddGroup(new GroupInfo(profile.Group), profilesChanged: false);

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

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

            group.Profiles.Add(profile);
        }

        ProfilesUpdated();
    }

    /// <summary>
    ///     Method to replace a profile in a group.
    /// </summary>
    /// <param name="oldProfile">Old profile as <see cref="ProfileInfo" />.</param>
    /// <param name="newProfile">New profile as <see cref="ProfileInfo" />.</param>
    /// <exception cref="ArgumentNullException">Thrown when oldProfile or newProfile is null.</exception>
    /// <exception cref="ArgumentException">Thrown when profile groups are null or empty.</exception>
    /// <exception cref="InvalidOperationException">Thrown when old profile's group is not found.</exception>
    public static void ReplaceProfile(ProfileInfo oldProfile, ProfileInfo newProfile)
    {
        ArgumentNullException.ThrowIfNull(oldProfile);

View on GitHub (pinned to 2780d65469)