nopSolutions/nopCommerce · warning · NopException
{titleRequiredLocale} (localized, formatted with languageNam
Error message
{titleRequiredLocale} (localized, formatted with languageName) What it means
ValidateTitleAndTextAsync throws NopException when 'title' is null or empty. The message is a localized resource (titleRequiredLocale) formatted with languageName, e.g. 'Admin.ArtificialIntelligence.ProductNameRequired'. This guards AI generation so it never runs without source text to base output on.
Source
Thrown at src/Libraries/Nop.Services/ArtificialIntelligence/ArtificialIntelligenceService.cs:275
#region Methods
/// <summary>
/// Validates title and text
/// </summary>
/// <param name="languageName">Target language name</param>
/// <param name="textRequiredLocale">Locale for raising an exception about the title field required</param>
/// <param name="titleRequiredLocale">Locale for raising an exception about the text field required</param>
/// <param name="title">Title for validate</param>
/// <param name="text">Text for validate</param>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the validated title and text
/// </returns>
public virtual async Task<(string title, string text)> ValidateTitleAndTextAsync(string languageName,
string textRequiredLocale, string titleRequiredLocale, string title, string text)
{
if (string.IsNullOrEmpty(title))
throw new NopException(string.Format(await _localizationService.GetResourceAsync(titleRequiredLocale), languageName));
if (!string.IsNullOrEmpty(text))
text = Regex.Replace(text, "<.*?>", string.Empty);
if (string.IsNullOrEmpty(text))
throw new NopException(string.Format(await _localizationService.GetResourceAsync(textRequiredLocale), languageName));
return (title, text);
}
/// <summary>
/// Create product description by artificial intelligence
/// </summary>
/// <param name="productName">Product name</param>
/// <param name="keywords">Features and keywords</param>
/// <param name="toneOfVoice">Tone of voice</param>
/// <param name="instruction">Special instruction</param>
/// <param name="customToneOfVoice">Custom tone of voice (applicable only for ToneOfVoiceType.Custom)</param>View on GitHub (pinned to 64bdf2ff08)
Solutions
- Ensure the entity has a non-empty title/name in the target language before requesting AI meta generation.
- Pre-check the localized name: if empty, prompt the user to fill it rather than invoking AI.
- Validate the chosen languageId resolves to a language that has the localized name.
Example fix
// before
var (t,k,d) = await _aiService.CreateMetaTagsAsync(entity, languageId); // throws if name empty
// after
var name = languageId == 0 ? entity.Name : await _localizationService.GetLocalizedAsync(entity, e => e.Name, languageId, false);
if (string.IsNullOrWhiteSpace(name))
return; // skip AI generation until name is set Defensive patterns
Strategy: validation
Validate before calling
var name = languageId == 0
? entity.Name
: await _localizationService.GetLocalizedAsync(entity, e => e.Name, languageId, false);
if (string.IsNullOrWhiteSpace(name))
// do not call AI meta generation; prompt user to set the name
return; Type guard
static bool HasTitleInLanguage<TEntity>(TEntity entity, int languageId, Func<TEntity,string> sel, ILocalizationService loc) where TEntity:BaseEntity,ILocalizedEntity
{
var v = languageId == 0 ? sel(entity) : loc.GetLocalizedAsync(entity, sel, languageId, false).GetAwaiter().GetResult();
return !string.IsNullOrWhiteSpace(v);
} Try / catch
try { await _aiService.CreateMetaTagsAsync(entity, languageId); }
catch (NopException ex) { /* title missing — prompt user to fill the name field */ } Prevention
- Require a non-empty name/title in the target language before exposing AI generation.
- Validate localized fields per language before invoking AI.
- Show inline validation on the name field before the AI button is enabled.
When it happens
Trigger: Calling CreateMetaTags/CreateProductDescription flows where the entity's title/name field (localized or not) resolves to an empty string — e.g. a Product with no Name, a BlogPost with no Title, in the target language.
Common situations: Generating meta tags for a new product/category/topic that has no name yet; localized entity missing the name in the target language (languageId resolves to empty); passing languageId that has no localized value.
Related errors
- {textRequiredLocale} (localized, formatted with languageName
- Admin.Common.UploadFile
- Email is not valid.
- {httpResponse.ReasonPhrase}
- {e.Message}
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/ccb7df4a9d8df8f5.
Report an issue: GitHub.