{"record":{"id":"58ad31c3725ef7d8","repo":"theonedev/onedev","slug":"unable-to-find-commit-to-import-build-spec-import","errorCode":null,"errorMessage":"Unable to find commit to import build spec (import project: {0}, import revision: {1})","messagePattern":"Unable to find commit to import build spec \\(import project: (.+?), import revision: (.+?)\\)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/Import.java","lineNumber":259,"sourceCode":"\t}\n\t\n\tpublic Project getProject() {\n\t\tif (project == null) {\n\t\t\tproject = OneDev.getInstance(ProjectService.class).findByPath(projectPath);\n\t\t\tif (project == null)\n\t\t\t\tthrow new ExplicitException(MessageFormat.format( _T(\"Unable to find project to import build spec: {0}\"), projectPath));\n\t\t}\n\t\treturn project;\n\t}\n\t\n\tpublic RevCommit getCommit() {\n\t\tif (commit == null) {\n\t\t\tcommit = getProject().getRevCommit(revision, false);\n\t\t\tif (commit == null) {\n\t\t\t\tString errorMessage = MessageFormat.format(\n\t\t\t\t\t\t_T(\"Unable to find commit to import build spec (import project: {0}, import revision: {1})\"),\n\t\t\t\t\t\tprojectPath, revision);\n\t\t\t\tthrow new ExplicitException(errorMessage);\n\t\t\t}\n\t\t}\n\t\treturn commit;\n\t}\n\t\n}\n","sourceCodeStart":241,"sourceCodeEnd":266,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/Import.java#L241-L266","documentation":"Import.getCommit resolves the import's revision string to a RevCommit via getProject().getRevCommit(revision, false). When the revision does not resolve to any commit in the imported project's repository, an ExplicitException naming project and revision is thrown.","triggerScenarios":"getCommit() called (via commit(), isValid()) when getRevCommit returns null — the revision is not a valid branch, tag, or commit hash in the imported project's git repository.","commonSituations":"Referenced branch was deleted or renamed; commit hash truncated/misspelled; revision exists locally but was never pushed to the OneDev server; tag removed after a release cleanup.","solutions":["Set `revision` to an existing branch, tag, or full commit hash in the imported project (verify with git rev-parse).","Push the referenced branch/commit to the OneDev server if it only exists locally.","Use a stable branch or tag instead of a short-lived branch that may be deleted."],"exampleFix":"// before: feature branch deleted\nimports:\n- project: shared/pipeline\n  revision: feature/tmp-spec\n// after\nimports:\n- project: shared/pipeline\n  revision: v1.2.0","handlingStrategy":"validation","validationCode":"// Verify revision resolves before authoring the import\ngit rev-parse --verify --quiet \"origin/<revision>^{commit}\" || echo \"revision missing\"","typeGuard":null,"tryCatchPattern":"try { import.getCommit(); } catch (ExplicitException e) { useDefaultRevision(e.getMessage()); }","preventionTips":["Push the referenced branch/tag before importing it.","Prefer tags or protected branches over ephemeral feature branches.","Check `git ls-remote` against the OneDev server, not just your local clone."],"tags":["git","revision","not-found","import"],"backgroundTag":"git-command-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"}