windmill-labs/windmill · error · Error

Could not get commit hash for repository

Error message

Could not get commit hash for repository

What it means

In frontend/src/lib/components/GitRepoResourcePicker.svelte:136, handleAddInventories calls a git-sync endpoint that returns a commit_hash; on failure it logs the original error and throws "Could not get commit hash for repository". It means the backend could not clone/fetch the repo (or resolve a commit) for the given resource/SSH identity.

Source

Thrown at frontend/src/lib/components/GitRepoResourcePicker.svelte:136

	}
	async function handleAddInventories() {
		if (!selectedResource || !inventoriesLocation.trim()) return

		loadingInventories = true
		try {
			// Get commit hash if not provided
			let commitHash = currentCommit
			if (!commitHash) {
				try {
					const result = await ResourceService.getGitCommitHash({
						workspace: ws!,
						path: selectedResource,
						gitSshIdentity: gitSshIdentity?.join(',')
					})
					commitHash = result.commit_hash
				} catch (err) {
					console.error('Failed to get commit hash:', err)
					throw new Error('Could not get commit hash for repository')
				}
			}

			if (!commitHash) {
				throw new Error('No commit hash available')
			}

			const inventoryFiles = await getInventoryFiles(
				selectedResource,
				inventoriesLocation.trim(),
				commitHash
			)

			// Dispatch event to update the script with additional_inventories
			dispatch('addInventories', {
				inventoryPaths: inventoryFiles
			})

View on GitHub (pinned to e474e8803c)

Solutions

  1. Check browser console for the logged 'Failed to get commit hash' cause
  2. Verify the git SSH identity resource has access to the repository
  3. Test repo reachability/clone manually with the same credentials
  4. Confirm the repo URL and default branch in the resource config
Defensive patterns

Strategy: try-catch

Validate before calling

if (!selectedResource) throw new Error('Select a git repository resource first');
if (needsIdentity && !gitSshIdentity?.length) throw new Error('Select an SSH identity with repo access');

Type guard

null

Try / catch

try {
  const result = await addInventories({ path: selectedResource, gitSshIdentity: gitSshIdentity?.join(',') });
  commitHash = result.commit_hash;
} catch (err) {
  console.error('Failed to get commit hash:', err); // original cause preserved
  sendUserToast('Could not reach repository: ' + (err.body?.message ?? err.message), true);
}

Prevention

When it happens

Trigger: The underlying request threw — bad repo URL, invalid or insufficiently-scoped SSH identity, unreachable git host, or repo/resource misconfigured — so result.commit_hash was never set.

Common situations: SSH key lacks access to the repo; wrong gitSshIdentity resource selected; firewall blocking the git host; repository path typo in the resource.

Related errors


AI-assisted analysis of windmill-labs/windmill@e474e8803c (2026-09-03). Data as JSON: /api/errors/2fcbaad18ec92637. Report an issue: GitHub.