nopSolutions/nopCommerce · warning · NopException
File {AvalaraTaxDefaults.TaxRatesFilePath} is empty
Error message
File {AvalaraTaxDefaults.TaxRatesFilePath} is empty What it means
The tax-rates fallback file exists on disk, but ReadAllTextAsync returned an empty or null string. The parser cannot produce rates from an empty file, so the plugin throws rather than silently returning zero tax.
Source
Thrown at src/Plugins/Nop.Plugin.Tax.Avalara/Services/AvalaraTaxManager.cs:673
/// </summary>
/// <returns>
/// A task that represents the asynchronous operation
/// The task result contains the tax rates list
/// </returns>
protected async Task<List<TaxRate>> GetTaxRatesFromFileAsync()
{
//try to create file if doesn't exist
var filePath = _fileProvider.MapPath(AvalaraTaxDefaults.TaxRatesFilePath);
if (!_fileProvider.FileExists(filePath))
await DownloadTaxRatesAsync();
if (!_fileProvider.FileExists(filePath))
throw new NopException($"File {AvalaraTaxDefaults.TaxRatesFilePath} not found");
//get file lines
var text = await _fileProvider.ReadAllTextAsync(filePath, Encoding.UTF8);
if (string.IsNullOrEmpty(text))
throw new NopException($"File {AvalaraTaxDefaults.TaxRatesFilePath} is empty");
var lines = text.Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
if (!lines.Any() || lines[0].Split(',').Length < 14)
throw new NopException($"Unsupported file {AvalaraTaxDefaults.TaxRatesFilePath} structure");
//prepare tax rates
var taxRates = lines.Skip(1).Select(line =>
{
try
{
var values = line.Split(',', StringSplitOptions.TrimEntries);
return new TaxRate
{
Zip = values[0], //ZIP_CODE
State = values[1], //STATE_ABBREV
County = values[2], //COUNTY_NAME
City = values[3], //CITY_NAME
StateTax = decimal.Parse(values[4], NumberStyles.Any, CultureInfo.InvariantCulture), //STATE_SALES_TAXView on GitHub (pinned to 64bdf2ff08)
Solutions
- Delete the empty file and trigger a fresh download from the admin area.
- Re-check Avalara credentials and network stability.
- Exclude the rates-file path from antivirus/proxy inspection.
- Verify no other process is writing to the file simultaneously.
Example fix
// before
if (string.IsNullOrEmpty(text))
throw new NopException($"File {AvalaraTaxDefaults.TaxRatesFilePath} is empty");
// after - treat empty as stale and retry the download once
if (string.IsNullOrEmpty(text))
{
_fileProvider.DeleteFile(filePath);
await DownloadTaxRatesAsync();
text = await _fileProvider.ReadAllTextAsync(filePath, Encoding.UTF8);
if (string.IsNullOrEmpty(text))
throw new NopException($"Tax rates file {AvalaraTaxDefaults.TaxRatesFilePath} is empty after re-download");
} Defensive patterns
Strategy: validation
Validate before calling
// Detect a zero-byte file and re-download proactively
var filePath = _fileProvider.MapPath(AvalaraTaxDefaults.TaxRatesFilePath);
if (_fileProvider.FileExists(filePath))
{
var info = new FileInfo(filePath);
if (info.Length == 0)
{
_fileProvider.DeleteFile(filePath);
await DownloadTaxRatesAsync();
}
} Prevention
- Treat a zero-byte rates file as a failed download and re-fetch it.
- Confirm Avalara credentials before relying on the offline fallback.
- Guard against concurrent writes to the rates file.
- Periodically validate the file has content in a health check.
When it happens
Trigger: DownloadTaxRatesAsync wrote a zero-byte file (interrupted download, empty 200 response, or a cancelled async write), or an external process truncated the file after it was written.
Common situations: Interrupted download leaving an empty file; proxy returning an empty 200 body; manual edit that cleared the contents; antivirus stripping content; concurrent writes racing.
Related errors
- File {AvalaraTaxDefaults.TaxRatesFilePath} not found
- Unsupported file {AvalaraTaxDefaults.TaxRatesFilePath} struc
- No tax category found with the specified id
- No record found
- Tax provider is not configured
AI-assisted analysis of nopSolutions/nopCommerce@64bdf2ff08 (2026-08-13).
Data as JSON: /api/errors/9c7f32b07554cba5.
Report an issue: GitHub.