windmill-labs/windmill · error · Error

No commit hash available

Error message

No commit hash available

What it means

In frontend/src/lib/components/GitRepoResourcePicker.svelte:141, after the add-inventories call, handleAddInventories checks commitHash and throws "No commit hash available" if it is still falsy (e.g. the API returned no commit_hash field). Downstream getInventoryFiles needs that hash to read files at a fixed ref.

Source

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

		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
			})

			// TODO: Add success feedback
		} catch (error) {
			console.error('Failed to load inventory files:', error)
			// TODO: Add error feedback
		} finally {

View on GitHub (pinned to e474e8803c)

Solutions

  1. Log/inspect the API response to see if commit_hash is present
  2. Update frontend/backend to matching versions
  3. Verify the repository is non-empty and has a resolvable HEAD
  4. Retry after confirming the repo works elsewhere (e.g. wmill CLI git sync)
Defensive patterns

Strategy: validation

Validate before calling

const result = await addInventories(args);
commitHash = result.commit_hash;
if (!commitHash) throw new Error('Backend returned no commit_hash for ' + selectedResource);

Type guard

function hasCommitHash(r: unknown): r is { commit_hash: string } {
  return !!r && typeof r === 'object' && typeof (r as any).commit_hash === 'string' && (r as any).commit_hash.length > 0;
}

Try / catch

if (!commitHash) {
  console.error('No commit hash in response — check backend version or repo state');
  sendUserToast('Repository returned no commit hash', true);
  return;
}

Prevention

When it happens

Trigger: The backend call succeeds but returns a response without commit_hash (or empty), so commitHash stays undefined before getInventoryFiles runs.

Common situations: Backend/API version mismatch where commit_hash was renamed or omitted; empty repository; backend bug swallowing the hash for certain repo types.

Related errors


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