nopSolutions/nopCommerce · error · NopException
LicenseKey is not set
Error message
LicenseKey is not set
What it means
Thrown by PrepareSecurity() in ItemClassificationHttpClient when _avalaraTaxSettings.LicenseKey is null. The license key is the secret half of the Basic-auth credential pair; without it the HS classification API call cannot be authenticated.
Source
Thrown at src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs:52
_avalaraTaxSettings = avalaraTaxSettings;
_httpClient = httpClient;
}
#endregion
#region Utilities
/// <summary>
/// Set security using CompanyId / License Key
/// </summary>
/// <returns>Security token</returns>
protected string PrepareSecurity()
{
if (_avalaraTaxSettings.AccountId is null)
throw new NopException("AccountId not set");
if (_avalaraTaxSettings.LicenseKey is null)
throw new NopException("LicenseKey is not set");
var s = $"{_avalaraTaxSettings.AccountId}:{_avalaraTaxSettings.LicenseKey}";
return Convert.ToBase64String(Encoding.UTF8.GetBytes(s));
}
#endregion
#region Methods
/// <summary>
/// Request services
/// </summary>
/// <typeparam name="TRequest">Request type</typeparam>
/// <typeparam name="TResponse">Response type</typeparam>
/// <param name="request">Request</param>
/// <returns>The asynchronous task whose result contains response details</returns>
public async Task<TResponse> RequestAsync<TRequest, TResponse>(TRequest request) where TRequest : Request where TResponse : Response
{View on GitHub (pinned to 64bdf2ff08)
Solutions
- Enter the Avalara LicenseKey (from Avalara account settings > Security) on the plugin configuration page.
- Confirm the key was not truncated or whitespace-trimmed on save.
- After rotation in Avalara, update the stored key in nopCommerce immediately.
Example fix
// before
if (_avalaraTaxSettings.LicenseKey is null)
throw new NopException("LicenseKey is not set");
// after — validate pair together at save time
if (string.IsNullOrWhiteSpace(model.LicenseKey))
ModelState.AddModelError(nameof(model.LicenseKey), "LicenseKey is required for HS classification"); Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrWhiteSpace(_avalaraTaxSettings.LicenseKey))
throw new InvalidOperationException("Avalara LicenseKey is required for HS classification"); Type guard
static bool HasLicenseKey(AvalaraTaxSettings s) => !string.IsNullOrWhiteSpace(s?.LicenseKey);
Try / catch
try { await client.RequestAsync<...,...>(req); }
catch (NopException ex) when (ex.Message == "LicenseKey is not set")
{ _notificationService.ErrorNotification("Enter your Avalara LicenseKey."); } Prevention
- Save AccountId and LicenseKey together.
- After rotating the key in Avalara, immediately update the stored value.
- Verify the key is not whitespace-trimmed on save.
When it happens
Trigger: HS classification request runs (RequestAsync) while the Avalara LicenseKey is missing from the plugin configuration.
Common situations: LicenseKey cleared/rotated but not re-entered; admin saved only AccountId; secret redacted during settings export/import.
Related errors
- AccountId not set
- Tax provider is not configured
- Item HS classification error: response content invalid - {ex
- Item HS classification error: {error}
- Data provider supports connection only with login and passwo
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/11267e2c9ace8a08.
Report an issue: GitHub.