windmill-labs/windmill · error

Workspace not found

Error message

Workspace not found

What it means

waitJob polls a job's result through the workspace API, so it needs to know which workspace to query. It reads forceWorkspace or the global workspaceStore; if neither yields a workspace (empty string/undefined) it throws 'Workspace not found' before starting to poll.

Source

Thrown at frontend/src/lib/components/waitJob.ts:16

import { JobService } from '$lib/gen'
import { workspaceStore } from '$lib/stores'
import { get } from 'svelte/store'

const ITERATIONS_BEFORE_SLOW_REFRESH = 10
const ITERATIONS_BEFORE_SUPER_SLOW_REFRESH = 100

export async function waitJob(id: string, forceWorkspace?: string) {
	const workspace = forceWorkspace || get(workspaceStore)

	if (!id) {
		return
	}

	if (!workspace) {
		throw new Error('Workspace not found')
	}

	let syncIteration: number = 0
	let errorIteration: number = 0
	let job: any

	return new Promise((resolve, reject) => {
		async function checkJob() {
			try {
				const maybeJob = await JobService.getCompletedJobResultMaybe({
					workspace: workspace!,
					id,
					getStarted: false
				})

				if (maybeJob.completed) {
					job = { ...maybeJob, id }

View on GitHub (pinned to e474e8803c)

Solutions

  1. Pass the workspace explicitly: waitJob(id, 'my-workspace') instead of relying on workspaceStore
  2. Ensure the user is logged in and workspaceStore is initialized before calling waitJob
  3. Guard the call site: skip waitJob when no workspace is available, mirroring the existing `if (!id) return` early return

Example fix

// before
await waitJob(jobId)
// after
const workspace = get(workspaceStore)
if (!workspace) throw new Error('Cannot wait for job: no active workspace')
await waitJob(jobId, workspace)
Defensive patterns

Strategy: validation

Validate before calling

const workspace = forceWorkspace || get(workspaceStore)
if (!workspace) throw new Error('waitJob requires an active workspace')

Type guard

function hasWorkspace(w: string | undefined | null): w is string { return typeof w === 'string' && w.length > 0 }

Try / catch

try {
  const result = await waitJob(id)
} catch (e) {
  if ((e as Error).message === 'Workspace not found') {
    // prompt user to select/login to a workspace before retrying
  }
}

Prevention

When it happens

Trigger: Calling waitJob(id) with no forceWorkspace argument while workspaceStore is unset/empty — e.g. the store was not initialized yet, the user is not logged into any workspace, or the caller runs outside a workspace-scoped page.

Common situations: Calling waitJob during app startup before the workspace store is populated; passing an empty-string workspace variable; invoking job-waiting logic from a context that has no active workspace (logged out, shared run page without workspace context).

Related errors


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