{"record":{"id":"51e0571109ea6ccf","repo":"theonedev/onedev","slug":"unable-to-find-version","errorCode":null,"errorMessage":"Unable to find version","messagePattern":"Unable to find version","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/data/migration/VersionedYamlDoc.java","lineNumber":86,"sourceCode":"\t\t\t}\n\t\t}\n\t\t\n        return (T) new OneYaml().construct(this);\n\t}\n\t\n\tpublic static VersionedYamlDoc fromBean(Object bean) {\n\t\tVersionedYamlDoc doc = new VersionedYamlDoc((MappingNode) new OneYaml().represent(bean));\n\t\tdoc.setVersion(MigrationHelper.getVersion(HibernateProxyHelper.getClassWithoutInitializingProxy(bean)));\n\t\treturn doc;\n\t}\n\t\n\tprivate String getVersion() {\n\t\tfor (NodeTuple tuple: getValue()) {\n\t\t\tScalarNode keyNode = (ScalarNode) tuple.getKeyNode();\n\t\t\tif (keyNode.getValue().equals(\"version\")) \n\t\t\t\treturn ((ScalarNode)tuple.getValueNode()).getValue();\n\t\t}\n\t\tthrow new ExplicitException(\"Unable to find version\");\n\t}\n\t\n\tprivate void removeVersion() {\n\t\tfor (Iterator<NodeTuple> it = getValue().iterator(); it.hasNext();) {\n\t\t\tScalarNode keyNode = (ScalarNode) it.next().getKeyNode();\n\t\t\tif (keyNode.getValue().equals(\"version\")) \n\t\t\t\tit.remove();\n\t\t}\n\t}\n\t\n\tprivate void setVersion(String version) {\n\t\tScalarNode versionNode = null;\n\t\tfor (NodeTuple tuple:  getValue()) {\n\t\t\tScalarNode keyNode = (ScalarNode) tuple.getKeyNode();\n\t\t\tif (keyNode.getValue().equals(\"version\")) {\n\t\t\t\t((ScalarNode) tuple.getValueNode()).setValue(version);\n\t\t\t\tbreak;\n\t\t\t}","sourceCodeStart":68,"sourceCodeEnd":104,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/data/migration/VersionedYamlDoc.java#L68-L104","documentation":"VersionedYamlDoc.getVersion scans the YAML mapping nodes for a top-level 'version' key, which records the doc format version used during migration. If no 'version' tuple exists, it throws ExplicitException('Unable to find version'), meaning the YAML cannot be safely deserialized to the current model.","triggerScenarios":"toBean calls getVersion on a YAML doc parsed from an import/backup file that lacks the mandatory 'version' key at the mapping root.","commonSituations":"Importing a YAML file hand-edited to drop the version field, files exported by older/incompatible tools, or YAML copied from documentation examples without the version entry.","solutions":["Add the missing 'version: N' key back at the top level of the YAML file with the correct version number","Re-export the data from the original OneDev version to regenerate a proper versioned YAML","Use the import feature of OneDev instead of hand-crafted YAML files","Check the file was not truncated — version is normally the first key"],"exampleFix":"# before\nname: my-project\nurl: https://example.com\n# after\nversion: 1\nname: my-project\nurl: https://example.com","handlingStrategy":"validation","validationCode":"// before deserializing YAML\ndoc.load(file);\nif (!doc.keySet().contains(\"version\")) rejectImport(file, \"missing version key\");","typeGuard":null,"tryCatchPattern":"try { VersionedYamlDoc.fromFile(f).toBean(type); } catch (ExplicitException e) { if (e.getMessage().equals(\"Unable to find version\")) { requireVersionedYaml(f); } }","preventionTips":["Always keep 'version' as the first key in versioned YAML files","Use OneDev's export feature rather than hand-writing YAML","Validate YAML against a versioned template before import","Diff hand-edited YAML against the original export"],"tags":["yaml","migration","missing-field"],"backgroundTag":"missing-required-config-field","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}