You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suspected breaking change in libmaxminddb v1.13.x #16
First of all thanks for your efforts on this package, it has proven valuable over the last few years. 👍
After we've recently updated libmaxminddb from v1.12.x to v1.13.x on our environments, we encountered a suspected breaking change: MMDB-files generated with this package are no longer readable, possibly due to recently introduced stricter validation in release v1.13.x.
$ mmdblookup --file test.mmdb --ip 1.1.0.0
Can't open test.mmdb - The MaxMind DB file's data section contains bad data (unknown data type or corrupt data)
Thanks for reporting this! I've identified the root cause and submitted a fix in #17.
Root Cause
libmaxminddb v1.13.0 added a new validation check in get_entry_data_list() (release notes):
if (offset >= mmdb->data_section_size||size> (mmdb->data_section_size-offset) / 2) {
returnMMDB_INVALID_DATA_ERROR;
}
This check is triggered during MMDB_open → read_metadata → populate_description_metadata, which calls MMDB_get_entry_data_list to parse the metadata.
In our metadata encoding, description was the last field. When description is an empty dict {} (the default when no languages are specified), the metadata section ends with \xe0 (MAP with 0 entries). The offset_to_next after this byte exactly equals metadata_section_size, causing offset >= data_section_size to evaluate to true — hence the "bad data" error.
Fix
Reorder metadata fields so that build_epoch (a scalar UINT64, not subject to the MAP/ARRAY validation) is always the last entry. This ensures empty description or languages values are never at the tail of the metadata section.
The fix is a one-line change in _build_meta() — just swapping the order of description and build_epoch.
Reacted by Mihai Limbășan and Ammar Hamilcar Tijani
Hello @vimt,
Brilliant, thanks for the quick follow up and RCA, much appreciated!
Confirmed: Everything operational again after upgrading this packages to v0.2.6. 👍
Activity
fix: compatibility with libmaxminddb v1.13.x stricter validation
vimt commentedon Mar 3, 2026
Thanks for reporting this! I've identified the root cause and submitted a fix in #17.
Root Cause
libmaxminddb v1.13.0 added a new validation check in
get_entry_data_list()(release notes):This check is triggered during
MMDB_open→read_metadata→populate_description_metadata, which callsMMDB_get_entry_data_listto parse the metadata.In our metadata encoding,
descriptionwas the last field. Whendescriptionis an empty dict{}(the default when no languages are specified), the metadata section ends with\xe0(MAP with 0 entries). Theoffset_to_nextafter this byte exactly equalsmetadata_section_size, causingoffset >= data_section_sizeto evaluate totrue— hence the "bad data" error.Fix
Reorder metadata fields so that
build_epoch(a scalarUINT64, not subject to the MAP/ARRAY validation) is always the last entry. This ensures emptydescriptionorlanguagesvalues are never at the tail of the metadata section.The fix is a one-line change in
_build_meta()— just swapping the order ofdescriptionandbuild_epoch.release: v0.2.6
Fix validation of empty maps/arrays at end of metadata
Fix validation of empty maps/arrays at end of metadata
Fix validation of empty maps/arrays at end of metadata
plivius commentedon Mar 4, 2026
Hello @vimt,
Brilliant, thanks for the quick follow up and RCA, much appreciated!
Confirmed: Everything operational again after upgrading this packages to
v0.2.6. 👍merge: sync fixes from master