{"record":{"id":"862b88c6fcaeb50f","repo":"nopSolutions/nopCommerce","slug":"packingpackagevolume-exceeds-max-package-size","errorCode":null,"errorMessage":"PackingPackageVolume exceeds max package size","messagePattern":"PackingPackageVolume exceeds max package size","errorType":"exception","errorClass":"NopException","httpStatus":null,"severity":"error","filePath":"src/Plugins/Nop.Plugin.Shipping.UPS/Services/UPSService.cs","lineNumber":662,"sourceCode":"            foreach (var item in shippingOptionRequest.Items)\n            {\n                //get dimensions and weight of the single item\n                var (itemWidth, itemLength, itemHeight) = await GetDimensionsForSingleItemAsync(item.ShoppingCartItem, item.Product);\n\n                totalVolume += item.GetQuantity() * itemWidth * itemLength * itemHeight;\n            }\n            \n            if (totalVolume > decimal.Zero)\n            {\n                //use default value (in cubic inches) if not specified\n                var packageVolume = _upsSettings.PackingPackageVolume;\n                if (packageVolume <= 0)\n                    packageVolume = 5184;\n\n                //calculate cube root (floor)\n                dimension = Convert.ToInt32(Math.Floor(Math.Pow(Convert.ToDouble(packageVolume), 1.0 / 3.0)));\n                if (GetPackageSize(dimension, dimension, dimension) > await GetSizeLimitAsync())\n                    throw new NopException(\"PackingPackageVolume exceeds max package size\");\n\n                //adjust package volume for dimensions calculated\n                packageVolume = dimension * dimension * dimension;\n\n                totalPackagesBySizeLimit = Convert.ToInt32(Math.Ceiling(totalVolume / packageVolume));\n            }\n\n            width = length = height = dimension;\n        }\n\n        //get total packages number according to package limits\n        var weight = await GetWeightAsync(shippingOptionRequest);\n        var weightLimit = await GetWeightLimitAsync();\n        var totalPackagesByWeightLimit = weight > weightLimit\n            ? Convert.ToInt32(Math.Ceiling(weight / weightLimit))\n            : 1;\n        var totalPackages = Math.Max(Math.Max(totalPackagesBySizeLimit, totalPackagesByWeightLimit), 1);\n","sourceCodeStart":644,"sourceCodeEnd":680,"githubUrl":"https://github.com/nopSolutions/nopCommerce/blob/64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2/src/Plugins/Nop.Plugin.Shipping.UPS/Services/UPSService.cs#L644-L680","documentation":"Thrown during package dimension calculation when the configured PackingPackageVolume (or its default of 5184 cubic inches) produces cube-root-derived dimensions whose combined girth+length exceeds the UPS size limit. The method computes a single dimension as the floor of the cube root, then checks GetPackageSize(dim, dim, dim) against GetSizeLimitAsync(). If the default or configured volume yields a package too large for UPS, this error fires.","triggerScenarios":"PackingPackageVolume setting is set to a value whose cube root (floored) multiplied by 3 (length + 2*(width+height) or similar girth calculation) exceeds the UPS size limit returned by GetSizeLimitAsync. Even the default 5184 yields dimension 17, giving size 17+17+17=51 which could exceed limits in certain configurations.","commonSituations":"Administrator set PackingPackageVolume to an excessively large value; UPS changed size limits in a newer API version; the weight/dimension type settings (IN/CM) interact with the limit calculation producing unexpected results; default volume is too large for certain UPS service types with reduced limits.","solutions":["Reduce the PackingPackageVolume setting at Admin > Configuration > Shipping > UPS to a smaller value (e.g. try 1728 for 12-inch cubes)","Verify the UPS DimensionsType setting (IN vs CM) — a CM-based volume in a setting expecting inches causes inflation","Check GetSizeLimitAsync() return value and ensure it reflects current UPS limits for your account/service type","Calculate the correct volume: if size limit is L, then max dimension = floor(L/3) and max volume = (floor(L/3))^3"],"exampleFix":"// before\n// PackingPackageVolume = 5184 (default) → dimension 17 → size 51\n\n// after — compute a safe volume from the size limit\nvar sizeLimit = await GetSizeLimitAsync(); // e.g. 165 inches\nvar maxDimension = Math.Floor(sizeLimit / 3.0);   // 55\nvar safeVolume = Math.Pow(maxDimension, 3);        // 166375\n// or simply set PackingPackageVolume to a conservative value\n_upsSettings.PackingPackageVolume = 1728; // 12-inch cube → size 36","handlingStrategy":"validation","validationCode":"// Validate PackingPackageVolume against the size limit before shipping\nvar sizeLimit = await GetSizeLimitAsync();\nvar dimension = Convert.ToInt32(Math.Floor(Math.Pow(Convert.ToDouble(_upsSettings.PackingPackageVolume <= 0 ? 5184 : _upsSettings.PackingPackageVolume), 1.0 / 3.0)));\nif (GetPackageSize(dimension, dimension, dimension) > sizeLimit)\n    throw new InvalidOperationException($\"PackingPackageVolume {_upsSettings.PackingPackageVolume} exceeds max package size {sizeLimit}\");","typeGuard":null,"tryCatchPattern":"// UPS errors throw directly; caller must catch\ntry\n{\n    var response = await _upsService.GetRatesAsync(request);\n}\ncatch (NopException ex) when (ex.Message.Contains(\"PackingPackageVolume\"))\n{\n    _logger.Error($\"UPS PackingPackageVolume too large; reduce it in settings: {ex.Message}\");\n    return ErrorResult(\"Shipping calculation unavailable due to package configuration\");\n}","preventionTips":["Calculate the safe maximum volume: maxDimension = floor(sizeLimit / 3), maxVolume = maxDimension^3","Keep PackingPackageVolume at the default (5184) unless a specific reason requires changing it","Verify the DimensionsType setting (IN vs CM) matches the volume unit to avoid unit mismatch","Add a configuration-time validation that warns admins if PackingPackageVolume produces dimensions exceeding the size limit"],"tags":["ups","package-volume","shipping","size-limit","configuration","nopcommerce"],"backgroundTag":null,"analyzedSha":"64bdf2ff08c8b39e65717bcf974fb43dc2ef68f2","analyzedAt":"2026-08-13T21:19:38.062Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}