theonedev/onedev · error · ExplicitException

Unable to find commit to import build spec (import project:

Error message

Unable to find commit to import build spec (import project: {0}, import revision: {1})

What it means

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.

Source

Thrown at server-core/src/main/java/io/onedev/server/buildspec/Import.java:259

	}
	
	public Project getProject() {
		if (project == null) {
			project = OneDev.getInstance(ProjectService.class).findByPath(projectPath);
			if (project == null)
				throw new ExplicitException(MessageFormat.format( _T("Unable to find project to import build spec: {0}"), projectPath));
		}
		return project;
	}
	
	public RevCommit getCommit() {
		if (commit == null) {
			commit = getProject().getRevCommit(revision, false);
			if (commit == null) {
				String errorMessage = MessageFormat.format(
						_T("Unable to find commit to import build spec (import project: {0}, import revision: {1})"),
						projectPath, revision);
				throw new ExplicitException(errorMessage);
			}
		}
		return commit;
	}
	
}

View on GitHub (pinned to d44925c47c)

Solutions

  1. Set `revision` to an existing branch, tag, or full commit hash in the imported project (verify with git rev-parse).
  2. Push the referenced branch/commit to the OneDev server if it only exists locally.
  3. Use a stable branch or tag instead of a short-lived branch that may be deleted.

Example fix

// before: feature branch deleted
imports:
- project: shared/pipeline
  revision: feature/tmp-spec
// after
imports:
- project: shared/pipeline
  revision: v1.2.0
Defensive patterns

Strategy: validation

Validate before calling

// Verify revision resolves before authoring the import
git rev-parse --verify --quiet "origin/<revision>^{commit}" || echo "revision missing"

Try / catch

try { import.getCommit(); } catch (ExplicitException e) { useDefaultRevision(e.getMessage()); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/58ad31c3725ef7d8. Report an issue: GitHub.