{"record":{"id":"992c990700a39496","repo":"nopSolutions/nopCommerce","slug":"item-hs-classification-error-error","errorCode":null,"errorMessage":"Item HS classification error: {error}","messagePattern":"Item HS classification error: (.+?)","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs","lineNumber":105,"sourceCode":"\n            //return result\n            TResponse result = null;\n            var responseString = await httpResponse.Content.ReadAsStringAsync();\n            try\n            {\n                result = JsonConvert.DeserializeObject<TResponse>(responseString ?? string.Empty);\n            }\n            catch (Exception ex)\n            {\n                throw new NopException($\"Item HS classification error: response content invalid - {ex.Message}\");\n            }\n            if (!string.IsNullOrEmpty(result?.Error?.Code))\n            {\n                var error = result.Error.Code;\n                if (result.Error.Details?.Any() ?? false)\n                    error += result.Error.Details.Aggregate(string.Empty, (text, e) => $\"{text}{e.Message} {e.Description};{Environment.NewLine}\");\n\n                throw new NopException($\"Item HS classification error: {error}\");\n            }\n\n            return result;\n        }\n        catch (AggregateException exception)\n        {\n            //rethrow actual exception\n            throw exception.InnerException;\n        }\n    }\n\n    #endregion\n}","sourceCodeStart":87,"sourceCodeEnd":118,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Tax.Avalara/Services/ItemClassificationHttpClient.cs#L87-L118","documentation":"Thrown when the deserialized HS classification response contains a non-empty result.Error.Code, meaning Avalara accepted and parsed the request but returned a structured application-level error. The message aggregates Error.Code plus any Details (each with Message and Description).","triggerScenarios":"Avalara rejects the classification request at the business level: invalid company, invalid item payload, missing required fields (country of destination, product info), quota exceeded, or permission errors.","commonSituations":"CountryOfDestination is null/invalid; Item payload missing required product identifiers; the AccountId/LicenseKey pair is valid but lacks HS-classification scope; rate limit/quota hit.","solutions":["Read the aggregated error details (Code + each Detail Message/Description) from the exception message — they name the exact field/problem.","Validate the CreateHSClassificationRequest payload (CountryOfDestination, Item fields) before sending.","Confirm the Avalara subscription includes the HS classification service for the target country."],"exampleFix":"// before\nthrow new NopException($\"Item HS classification error: {error}\");\n\n// after — surface details as a typed record\nthrow new NopException($\"Item HS classification error: {error.Code}\", new HsClassificationApiException\n{\n    Code = error.Code,\n    Details = error.Details?.Select(d => (d.Message, d.Description)).ToList()\n});","handlingStrategy":"try-catch","validationCode":"var missing = new[] { classificationModel.CountryOfDestination, classificationModel.Item?.Code }.Where(string.IsNullOrWhiteSpace).ToList();\nif (missing.Any()) throw new NopException($\"HS classification missing fields: {string.Join(\",\", missing)}\");","typeGuard":"static bool IsValidClassificationRequest(CreateHSClassificationRequest r) => !string.IsNullOrWhiteSpace(r?.CountryOfDestination) && r?.Item is not null;","tryCatchPattern":"try { await client.RequestAsync<TReq,TResp>(request); }\ncatch (NopException ex) when (ex.Message.Contains(\"Item HS classification error\"))\n{ _logger.LogError(ex, \"Avalara rejected HS classification: {Msg}\", ex.Message); throw; }","preventionTips":["Validate CountryOfDestination and Item payload before sending.","Confirm the Avalara subscription covers HS classification for the destination country.","Surface Avalara's per-field Details to the operator for faster triage."],"tags":["avalara","hs-classification","api-error","validation","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}