{"record":{"id":"a47e1f7cc2755867","repo":"theonedev/onedev","slug":"incorrect-data-format-no-data-version","errorCode":null,"errorMessage":"Incorrect data format: no data version","messagePattern":"Incorrect data format: no data version","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/data/DefaultDataService.java","lineNumber":340,"sourceCode":"\n\tprivate File getVersionFile(File dataDir) {\n\t\tFile versionFile = new File(dataDir, ModelVersion.class.getSimpleName() + \"s.xml\");\n\t\tif (!versionFile.exists())\n\t\t\tversionFile = new File(dataDir, \"VersionTables.xml\");\n\t\treturn versionFile;\n\t}\n\t\n\t@Override\n\tpublic void migrateData(File dataDir) {\n\t\tFile versionFile = getVersionFile(dataDir);\n\t\t\n\t\tVersionedXmlDoc dom = VersionedXmlDoc.fromFile(versionFile);\n\t\tList<Element> elements = dom.getRootElement().elements();\n\t\tif (elements.size() != 1)\n\t\t\tthrow new RuntimeException(\"Incorrect data format: illegal data version\");\n\t\tElement versionElement = elements.iterator().next().element(ModelVersion.PROP_VERSION_COLUMN);\t\t\n\t\tif (versionElement == null) {\n\t\t\tthrow new RuntimeException(\"Incorrect data format: no data version\");\n\t\t}\n\t\t\n\t\tif (MigrationHelper.migrate(versionElement.getText(), new DataMigrator(), dataDir)) {\n\t\t\t// load version file again in case we changed something of it while migrating\n\t\t\tversionFile = getVersionFile(dataDir);\n\t\t\tdom = VersionedXmlDoc.fromFile(versionFile);\n\t\t\telements = dom.getRootElement().elements();\n\t\t\tPreconditions.checkState(elements.size() == 1);\n\t\t\tversionElement = Preconditions.checkNotNull(elements.iterator().next().element(ModelVersion.PROP_VERSION_COLUMN));\t\t\n\t\t\tversionElement.setText(MigrationHelper.getVersion(DataMigrator.class));\n\t\t\tdom.writeToFile(versionFile, false);\n\t\t}\t\t\n\t}\n\n\t/**\n\t * Determines whether or not entityType1 has transitive foreign key\n\t * dependency on entityType2.\n\t * ","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/data/DefaultDataService.java#L322-L358","documentation":"migrateData locates the version element by looking up child element ModelVersion.PROP_VERSION_COLUMN under the single root child of the db_version XML file. If that element is missing, the file has no data version recorded and it throws this RuntimeException.","triggerScenarios":"The db_version XML file exists with exactly one root child, but that child lacks the 'version' column element — e.g. the file was hand-edited or generated incorrectly.","commonSituations":"Manual editing/removal of the version entry in the site data directory, corrupted export, or copy-pasting a wrong file structure into db_version.","solutions":["Restore the db_version file from backup and ensure it contains a <version>N</version> entry","Recreate the file with the proper structure: single child element containing the version column element","If the site data version cannot be determined, re-initialize the data directory","Check the file with the same OneDev version to confirm the expected structure"],"exampleFix":"<!-- before -->\n<root><other>10</other></root>\n<!-- after -->\n<root><version>10</version></root>","handlingStrategy":"validation","validationCode":"Element versionEl = (Element) dom.getRootElement().elements().get(0).element(\"version\");\nif (versionEl == null) restoreFromBackup(dbVersionFile);","typeGuard":null,"tryCatchPattern":"try { migrateData(dir); } catch (RuntimeException e) { if (e.getMessage().contains(\"no data version\")) { recreateDbVersionFile(); } }","preventionTips":["Preserve the <version> element when editing any versioned file","Take backups of data-dir metadata files","Never regenerate the version file by hand — copy from a working install","Use OneDev's own export/import instead of manual file surgery"],"tags":["data-format","xml","migration"],"backgroundTag":"schema-validation-failed","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}