{"record":{"id":"1b3f5d0887d4696c","repo":"elastic/elasticsearch","slug":"database-type-too-long-size-indicator","errorCode":null,"errorMessage":"database_type too long [size indicator == {}]","messagePattern":"database_type too long \\[size indicator == (.+?)\\]","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"modules/ip-location/src/main/java/org/elasticsearch/ingest/geoip/MMDBUtil.java","lineNumber":93,"sourceCode":"            if (metadataOffset == -1) {\n                throw new IOException(\"database type marker not found\");\n            }\n\n            // read the database type\n            final int offsetByte = fromBytes(tail[metadataOffset]);\n            final int type = offsetByte >>> 5;\n            if (type != 2) { // 2 is the type indicator in the mmdb format for a UTF-8 string\n                throw new IOException(\"type must be UTF-8 string\");\n            }\n            int size = offsetByte & 0x1f;\n            if (size == 29) {\n                // then we need to read in yet another byte and add it onto this size\n                // this can actually occur in practice, a 29+ character type description isn't that hard to imagine\n                size = 29 + fromBytes(tail[metadataOffset + 1]);\n                metadataOffset += 1;\n            } else if (size >= 30) {\n                // we'd need to read two or three more bytes to get the size, but this means the type length is >=285\n                throw new IOException(\"database_type too long [size indicator == \" + size + \"]\");\n            }\n\n            return new String(tail, metadataOffset + 1, size, StandardCharsets.UTF_8);\n        }\n    }\n\n    private static int fromBytes(byte b1) {\n        return b1 & 0xFF;\n    }\n\n    public static boolean isGzip(Path path) throws IOException {\n        try (InputStream is = Files.newInputStream(path); InputStream gzis = new GZIPInputStream(is)) {\n            gzis.read(); // nooping, the point is just whether it's a gzip or not\n            return true;\n        } catch (ZipException e) {\n            return false;\n        }\n    }","sourceCodeStart":75,"sourceCodeEnd":111,"githubUrl":"https://github.com/elastic/elasticsearch/blob/db6a809a667c081ca1dc7500389d26975573215f/modules/ip-location/src/main/java/org/elasticsearch/ingest/geoip/MMDBUtil.java#L75-L111","documentation":"Thrown by MMDBUtil.getDatabaseType when the database_type field's size indicator is >= 30, meaning the type string would be >= 285 characters. Real Maxmind/Ipinfo type strings are short (e.g. 'GeoIP2-City', 'ipinfo country'); an oversized indicator signals a corrupt metadata section. IOException surfaces during lookup wiring.","triggerScenarios":"getDatabaseType: size = offsetByte & 0x1f; size >= 30 -> throw. The mmdb extended-size encoding would require two or three more bytes, which the implementation declines to parse.","commonSituations":"Corrupt mmdb metadata giving a garbage size byte; a non-mmdb file whose post-marker byte happens to have low 5 bits >= 30; bit-level corruption.","solutions":["Validate the file with the official mmdb tool.","Re-download the database to eliminate corruption.","Confirm the file is genuinely mmdb and not another format that matched the marker by chance.","If a legitimate type is extremely long (unlikely), the size parsing would need extension (code change)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    String type = MMDBUtil.getDatabaseType(path);\n} catch (IOException e) {\n    if (e.getMessage().startsWith(\"database_type too long\")) {\n        // size byte indicates a corrupt metadata section; re-download and revalidate\n    } else throw e;\n}","preventionTips":["Validate mmdb files with the official tool.","Re-download on corruption.","Confirm the file is genuinely mmdb before parsing metadata.","Capture reproducible corrupt files for a bug report."],"tags":["geoip","mmdb","metadata","data-integrity","corruption"],"backgroundTag":null,"analyzedSha":"db6a809a667c081ca1dc7500389d26975573215f","analyzedAt":"2026-08-12T01:39:14.192Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}