windmill-labs/windmill · error

<server response text>

Error message

<server response text>

What it means

expandMarker() POSTs SQL/Python content to the server's /internal_db/expand_marker endpoint to expand schema markers into full SQL. On any non-OK HTTP response it throws an Error whose message is the raw response body text — so the message text is whatever the server returned (validation error, 500 detail, auth failure, etc.).

Source

Thrown at frontend/src/lib/components/dbOps.ts:615

export function getDatabaseArg(input: DbInput | undefined) {
	if (input?.type === 'database') {
		if (input.resourcePath.startsWith('datatable://')) {
			return { database: input.resourcePath }
		} else {
			return { database: '$res:' + input.resourcePath }
		}
	}
	return {}
}

async function expandMarker(workspace: string, language: string, content: string): Promise<string> {
	const response = await fetch(`/api/w/${workspace}/internal_db/expand_marker`, {
		method: 'POST',
		headers: { 'Content-Type': 'application/json' },
		body: JSON.stringify({ language, content })
	})
	if (!response.ok) {
		throw new Error(await response.text())
	}
	const result = (await response.json()) as { code: string }
	return result.code
}

View on GitHub (pinned to e474e8803c)

Solutions

  1. Read the error message — it is the server's response body and states the actual failure.
  2. If 401/403, re-login or check workspace permissions for internal_db endpoints.
  3. Validate the marker syntax and language field against what the dbOps editor normally generates.
  4. If 500, retry and check server logs; the payload may expose a backend bug worth reporting.
  5. Confirm the backend version supports expand_marker (older backends return 404).

Example fix

// before
const code = await expandMarker(ws, language, content) // throws raw server text
// after
try {
  const code = await expandMarker(ws, language, content)
} catch (e) {
  console.error('expand_marker failed:', e.message) // server response text
  if (e.message.includes('40')) showToast('Check login and marker syntax')
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!content?.trim()) return '' // nothing to expand
if (!navigator.onLine) showToast('No network connection')

Type guard

function isOkResponse(res: Response): boolean {
  return res.ok
}

Try / catch

try {
  const code = await expandMarker(ws, language, content)
} catch (e) {
  // e.message is the raw server response body
  if (/401|403|unauthorized/i.test(e.message)) {
    await relogin()
  } else {
    console.error('expand_marker server error:', e.message)
  }
  throw e
}

Prevention

When it happens

Trigger: The server responds 4xx/5xx to the expand_marker call: malformed content/language payload, marker syntax the server cannot parse, workspace auth failure (401/403), or an internal error while processing the SQL.

Common situations: Expired session/token yielding 401; editing a dbOps script with a hand-written marker the backend rejects; server-side bug or DB outage producing a 500; calling from a workspace where internal DB features are unavailable.

Understand the failure class

Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.

Related errors


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