nopSolutions/nopCommerce · error · Exception

A theme with '{themeDescriptor.SystemName}' system name is a

Error message

A theme with '{themeDescriptor.SystemName}' system name is already defined

What it means

Thrown by ThemeProvider.GetThemeDescriptorFromText when a freshly parsed ThemeDescriptor's SystemName already exists in the _themeDescriptors cache. GetThemeDescriptorFromText checks ContainsKey against the cache populated by prior calls.

Source

Thrown at src/Libraries/Nop.Services/Themes/ThemeProvider.cs:64

                throw new Exception($"A theme descriptor '{descriptionFile}' has no system name");

            _themeDescriptors.TryAdd(themeDescriptor.SystemName, themeDescriptor);
        }
    }

    /// <summary>
    /// Get theme descriptor from the description text
    /// </summary>
    /// <param name="text">Description text</param>
    /// <returns>Theme descriptor</returns>
    public ThemeDescriptor GetThemeDescriptorFromText(string text)
    {
        //get theme description from the JSON file
        var themeDescriptor = JsonConvert.DeserializeObject<ThemeDescriptor>(text);

        //some validation
        if (_themeDescriptors.ContainsKey(themeDescriptor.SystemName))
            throw new Exception($"A theme with '{themeDescriptor.SystemName}' system name is already defined");

        return themeDescriptor;
    }

    /// <summary>
    /// Get all themes
    /// </summary>
    /// <returns>
    /// A task that represents the asynchronous operation
    /// The task result contains the list of the theme descriptor
    /// </returns>
    public virtual Task<IList<ThemeDescriptor>> GetThemesAsync()
    {
        return Task.FromResult<IList<ThemeDescriptor>>(_themeDescriptors.Values.ToList());
    }

    /// <summary>
    /// Get a theme by the system name

View on GitHub (pinned to 64bdf2ff08)

Solutions

  1. Give each theme a unique SystemName in its themeDescription.json.
  2. Remove the duplicate theme folder so only one definition remains.
  3. After renaming, clear any theme cache and restart the app.

Example fix

// before: two folders both have
{ "SystemName": "DefaultClean" }
// after: rename the fork
{ "SystemName": "DefaultCleanFork" }
Defensive patterns

Strategy: validation

Validate before calling

var desc = JsonConvert.DeserializeObject<ThemeDescriptor>(text);
if (existing.ContainsKey(desc.SystemName))
    // rename SystemName or remove duplicate folder before parse

Type guard

static bool IsUniqueSystemName(string json, IDictionary<string,ThemeDescriptor> known)
    => !known.ContainsKey(JsonConvert.DeserializeObject<ThemeDescriptor>(json).SystemName);

Try / catch

try { themeProvider.GetThemeDescriptorFromText(text); }
catch (Exception ex) when (ex.Message.Contains("already defined"))
{ logger.Warn($"Duplicate theme: {ex.Message}"); }

Prevention

When it happens

Trigger: Two theme folders each declare the same SystemName in their themeDescription.json; or the same theme is parsed twice. Because _themeDescriptors is populated by the scan and this method also checks it, a duplicate SystemName triggers the throw.

Common situations: Duplicating a theme folder to fork it without renaming SystemName; installing two theme packages that share a SystemName; leftover theme copies from a failed deploy.

Related errors


AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13). Data as JSON: /api/errors/a9f45c9c8f368618. Report an issue: GitHub.