{"record":{"id":"4cbbbef7da9511f0","repo":"t8y2/dbx","slug":"unsupported-h2-database-file-format-format","errorCode":null,"errorMessage":"Unsupported H2 database file format: \" + format","messagePattern":"Unsupported H2 database file format: \" \\+ format","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"agents/drivers/h2/src/main/java/com/dbx/agent/h2/H2DriverVersion.java","lineNumber":62,"sourceCode":"        return switch (normalized) {\n            case \"h2-v1\" -> V1;\n            case \"h2-v2\", \"h2-legacy\" -> V2;\n            case \"h2-v3\" -> V3;\n            case \"h2-custom\" -> CUSTOM;\n            case \"\", \"h2\", \"h2-auto\", \"h2_embedded\", \"h2_server\" -> {\n                java.util.OptionalInt detected = H2FileFormatDetector.detect(H2Agent.buildUrl(params));\n                yield detected.isPresent() ? fromStorageFormat(detected.getAsInt()) : V3;\n            }\n            default -> throw new IllegalArgumentException(\"Unsupported H2 driver profile: \" + profile);\n        };\n    }\n\n    private static H2DriverVersion fromStorageFormat(int format) {\n        return switch (format) {\n            case 1 -> V1;\n            case 2 -> V2;\n            case 3 -> V3;\n            default -> throw new IllegalArgumentException(\"Unsupported H2 database file format: \" + format);\n        };\n    }\n}\n","sourceCodeStart":44,"sourceCodeEnd":66,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/agents/drivers/h2/src/main/java/com/dbx/agent/h2/H2DriverVersion.java#L44-L66","documentation":"H2FileFormatDetector detects the storage format from on-disk files and H2DriverVersion.fromStorageFormat maps the detected numeric format (1=PageStore, 2/3=MVStore versions) to a driver version. Formats outside 1..3 indicate corrupt or unrecognized header data, so this IllegalArgumentException is thrown.","triggerScenarios":"H2FileFormatDetector.detect returned an unexpected integer (e.g. from a corrupted or future-format MVStore header) which is then passed to fromStorageFormat.","commonSituations":"Database file corrupted by a crash or partial write; H2 database created by a newer H2 version with an unknown format code; a non-H2 file renamed to .mv.db and scanned.","solutions":["Verify the database file with the H2 Shell tool (java -cp h2.jar org.h2.tools.Shell) to check integrity and actual version","Restore the database from backup if headers are corrupted","Upgrade the driver module to a version that supports the newer storage format"],"exampleFix":"// before (corrupt header detected as format 7)\n// fromStorageFormat(7) -> throws\n// after: restore valid DB file\n// detect(base) -> 3 -> V3","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    H2DriverVersion v = H2DriverVersion.select(profile, params);\n} catch (IllegalArgumentException e) {\n    // detected format unsupported: check DB integrity / upgrade driver\n    throw new RuntimeException(\"H2 file format not supported by this agent; restore or upgrade\", e);\n}","preventionTips":["Keep the H2 driver module updated when upgrading the H2 database version","Validate database files after restores and upgrades (H2 Shell/Recover tool)","Never rename arbitrary files to .mv.db / .h2.db"],"tags":["h2","corruption","format-detection","illegal-argument"],"backgroundTag":"corrupt-database-file","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}