{"record":{"id":"11267e2c9ace8a08","repo":"nopSolutions/nopCommerce","slug":"licensekey-is-not-set","errorCode":null,"errorMessage":"LicenseKey is not set","messagePattern":"LicenseKey is not set","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs","lineNumber":52,"sourceCode":"        _avalaraTaxSettings = avalaraTaxSettings;\n        _httpClient = httpClient;\n    }\n\n    #endregion\n\n    #region Utilities\n\n    /// <summary>\n    /// Set security using CompanyId / License Key\n    /// </summary>\n    /// <returns>Security token</returns>\n    protected string PrepareSecurity()\n    {\n        if (_avalaraTaxSettings.AccountId is null)\n            throw new NopException(\"AccountId not set\");\n\n        if (_avalaraTaxSettings.LicenseKey is null)\n            throw new NopException(\"LicenseKey is not set\");\n\n        var s = $\"{_avalaraTaxSettings.AccountId}:{_avalaraTaxSettings.LicenseKey}\";\n        return Convert.ToBase64String(Encoding.UTF8.GetBytes(s));\n    }\n\n    #endregion\n\n    #region Methods\n\n    /// <summary>\n    /// Request services\n    /// </summary>\n    /// <typeparam name=\"TRequest\">Request type</typeparam>\n    /// <typeparam name=\"TResponse\">Response type</typeparam>\n    /// <param name=\"request\">Request</param>\n    /// <returns>The asynchronous task whose result contains response details</returns>\n    public async Task<TResponse> RequestAsync<TRequest, TResponse>(TRequest request) where TRequest : Request where TResponse : Response\n    {","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs#L34-L70","documentation":"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.","triggerScenarios":"HS classification request runs (RequestAsync) while the Avalara LicenseKey is missing from the plugin configuration.","commonSituations":"LicenseKey cleared/rotated but not re-entered; admin saved only AccountId; secret redacted during settings export/import.","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."],"exampleFix":"// before\nif (_avalaraTaxSettings.LicenseKey is null)\n    throw new NopException(\"LicenseKey is not set\");\n\n// after — validate pair together at save time\nif (string.IsNullOrWhiteSpace(model.LicenseKey))\n    ModelState.AddModelError(nameof(model.LicenseKey), \"LicenseKey is required for HS classification\");","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(_avalaraTaxSettings.LicenseKey))\n    throw new InvalidOperationException(\"Avalara LicenseKey is required for HS classification\");","typeGuard":"static bool HasLicenseKey(AvalaraTaxSettings s) => !string.IsNullOrWhiteSpace(s?.LicenseKey);","tryCatchPattern":"try { await client.RequestAsync<...,...>(req); }\ncatch (NopException ex) when (ex.Message == \"LicenseKey is not set\")\n{ _notificationService.ErrorNotification(\"Enter your Avalara LicenseKey.\"); }","preventionTips":["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."],"tags":["avalara","hs-classification","configuration","authentication","secrets","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}