nopSolutions/nopCommerce · error · NopException
ArtificialIntelligence.CreateProductFailed
Error message
ArtificialIntelligence.CreateProductFailed
What it means
CreateProductDescriptionAsync wraps its SendQueryAsync + Markdown.ToHtml call in try/catch. On any exception it logs the error then throws NopException whose message is the localized resource 'ArtificialIntelligence.CreateProductFailed' formatted with e.Message. So callers see a user-facing 'product creation failed: <inner detail>' message while the original exception (with stack) is preserved only in the log.
Source
Thrown at src/Libraries/Nop.Services/ArtificialIntelligence/ArtificialIntelligenceService.cs:320
if (languageId == 0)
languageId = _localizationSettings.DefaultAdminLanguageId;
var lang = await _languageService.GetLanguageByIdAsync(languageId);
var query = string.Format(string.IsNullOrEmpty(_artificialIntelligenceSettings.ProductDescriptionQuery) ? ArtificialIntelligenceDefaults.ProductDescriptionQuery : _artificialIntelligenceSettings.ProductDescriptionQuery, productName, keywords, toneOfVoiceInstruction, instruction, lang.Name);
try
{
var result = await _httpClient.SendQueryAsync(query);
return Markdown.ToHtml(result);
}
catch (Exception e)
{
var customer = await _workContext.GetCurrentCustomerAsync();
await _logger.ErrorAsync(e.Message, e, customer);
throw new NopException(string.Format(await _localizationService.GetResourceAsync("ArtificialIntelligence.CreateProductFailed"), e.Message));
}
}
/// <summary>
/// Create meta tags by artificial intelligence
/// </summary>
/// <param name="entity">The entity to which need to generate meta tags</param>
/// <param name="languageId">The language identifier</param>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the generated meta tags
/// </returns>
public virtual async Task<(string metaTitle, string metaKeywords, string metaDescription)> CreateMetaTagsForLocalizedEntityAsync<TEntity>(TEntity entity, int languageId)
where TEntity : BaseEntity, IMetaTagsSupported, ILocalizedEntity
{
var currentMetaTitle = languageId == 0
? entity.MetaTitle
: await _localizationService.GetLocalizedAsync(entity, mt => mt.MetaTitle, languageId, false);View on GitHub (pinned to 64bdf2ff08)
Solutions
- Inspect the log: the full original exception (message + stack) is recorded before the wrapped throw.
- Fix the underlying AI provider error — verify API key, quota, network, RequestTimeout for the configured ProviderType.
- Catch the NopException in the UI layer and show the localized failure to the merchant without blocking product save.
- On transient errors, retry with backoff; consider increasing RequestTimeout.
Example fix
// before
var html = await _aiService.CreateProductDescriptionAsync(name, keywords, tone, instruction, custom, langId);
// after
try
{
var html = await _aiService.CreateProductDescriptionAsync(name, keywords, tone, instruction, custom, langId);
}
catch (NopException ex)
{
// show user-friendly message; do not block saving the product
NotifyError(ex.Message);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Validate AI settings before generating
if (string.IsNullOrWhiteSpace(_aiSettings.Token))
throw new InvalidOperationException("AI provider API key is not configured."); Try / catch
try { var html = await _aiService.CreateProductDescriptionAsync(name, keywords, tone, instruction, custom, langId); }
catch (NopException ex) { NotifyError(ex.Message); /* do not block product save */ } Prevention
- Treat AI product-description generation as optional; catch NopException in the UI.
- Verify the API key/quota/network for the configured ProviderType.
- Check the log for the original exception (recorded with full stack) to find root cause.
- Set a sensible RequestTimeout and retry transient failures.
When it happens
Trigger: Invoking AI product-description generation when SendQueryAsync fails (provider 4xx/5xx, auth, quota, timeout) or when ParseResponse/Markdown.ToHtml throws on a malformed provider response.
Common situations: Invalid/expired AI API key; provider rate limit/quota; network blocked to the AI endpoint; RequestTimeout too short; provider returns an unexpected JSON shape that fails ParseResponse; Markdown conversion of empty/odd output.
Related errors
- {httpResponse.ReasonPhrase}
- {e.Message}
- {titleRequiredLocale} (localized, formatted with languageNam
- {textRequiredLocale} (localized, formatted with languageName
- No product found with the specified id
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/0c4665a3e658cc79.
Report an issue: GitHub.