{"record":{"id":"1f1cff9210b57293","repo":"nopSolutions/nopCommerce","slug":"accountid-not-set","errorCode":null,"errorMessage":"AccountId not set","messagePattern":"AccountId not set","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs","lineNumber":49,"sourceCode":"        httpClient.DefaultRequestHeaders.Add(HeaderNames.UserAgent, AvalaraTaxDefaults.UserAgent);\n        httpClient.DefaultRequestHeaders.Add(HeaderNames.Accept, MimeTypes.ApplicationJson);\n\n        _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>","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs#L31-L67","documentation":"Thrown by PrepareSecurity() in ItemClassificationHttpClient when _avalaraTaxSettings.AccountId is null. PrepareSecurity builds the Basic-auth token '{AccountId}:{LicenseKey}' base64-encoded for the HS classification API, so both values are mandatory.","triggerScenarios":"Any HS classification HTTP request is sent (RequestAsync) while the Avalara AccountId has not been entered in the plugin configuration.","commonSituations":"Plugin configured with LicenseKey but AccountId left blank, or vice-versa; fresh install; settings cleared after DB migration.","solutions":["Enter the Avalara AccountId (found in the Avalara account settings) on the plugin configuration page.","Ensure both AccountId AND LicenseKey are saved together — the validation should require both.","Verify the settings saved to the correct store scope."],"exampleFix":"// before\nif (_avalaraTaxSettings.AccountId is null)\n    throw new NopException(\"AccountId not set\");\n\n// after — fail fast at config-save time in the controller\nif (string.IsNullOrWhiteSpace(model.AccountId) || string.IsNullOrWhiteSpace(model.LicenseKey))\n    ModelState.AddModelError(string.Empty, \"Avalara AccountId and LicenseKey are both required\");","handlingStrategy":"validation","validationCode":"if (string.IsNullOrWhiteSpace(_avalaraTaxSettings.AccountId))\n    throw new InvalidOperationException(\"Avalara AccountId is required for HS classification\");","typeGuard":"static bool HasAccountId(AvalaraTaxSettings s) => !string.IsNullOrWhiteSpace(s?.AccountId);","tryCatchPattern":"try { await _itemClassificationHttpClient.RequestAsync<...,...>(req); }\ncatch (NopException ex) when (ex.Message == \"AccountId not set\")\n{ _notificationService.ErrorNotification(\"Enter your Avalara AccountId.\"); }","preventionTips":["Require both AccountId and LicenseKey on the plugin config form.","Run a connection test on config save that calls PrepareSecurity.","Store credentials in a secrets store rather than plaintext settings."],"tags":["avalara","hs-classification","configuration","authentication","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}