windmill-labs/windmill · error

Database not found

Error message

Database not found

What it means

After fetching the resource, the db-schema tool inspects it and produces a schema descriptor; when the resource cannot be resolved into a database schema (missing resource, non-database resource type, or unsupported/failed introspection) it returns null and the tool throws 'Database not found'.

Source

Thrown at frontend/src/lib/components/copilot/chat/script/core.ts:496

				throw new Error('Database path not provided')
			}
			toolCallbacks.setToolStatus(toolId, {
				content: 'Getting database schema for ' + args.resourcePath + '...'
			})
			const resource = await ResourceService.getResource({
				workspace: workspace,
				path: args.resourcePath
			})
			const dbSchema = await getDbSchemas(
				resource.resource_type,
				args.resourcePath,
				workspace,
				(error) => {
					console.error(error)
				}
			)
			if (!dbSchema) {
				throw new Error('Database not found')
			}
			// The dbSchemas store is an editor cache keyed by resource path with no
			// workspace dimension: a chat that may operate on a different workspace than
			// the navigation one (global/session) must not write into it.
			if (updateEditorCache) {
				dbSchemas.update((schemas) => ({ ...schemas, [args.resourcePath]: dbSchema }))
			}
			const stringSchema = await formatDBSchema(dbSchema)
			toolCallbacks.setToolStatus(toolId, {
				content: 'Retrieved database schema for ' + args.resourcePath
			})
			return stringSchema
		}
	}
}

export const dbSchemaTool: Tool<ScriptChatHelpers> = createDbSchemaTool<ScriptChatHelpers>()

View on GitHub (pinned to e474e8803c)

Solutions

  1. Confirm the resource path exists in the current workspace (resource list or /resources page)
  2. Check the resource is a database kind (postgresql, mysql, etc.) the tool supports
  3. Verify workspace/permissions: the chat workspace must be able to read the resource
  4. Fix the resource's configuration (connection string/fields) so introspection can run

Example fix

// before
{ resourcePath: 'u/admin/marekting_db' } // typo -> 'Database not found'
// after
{ resourcePath: 'u/admin/marketing_db' }
Defensive patterns

Strategy: validation

Validate before calling

const resource = await ResourceService.getResource({ workspace, path: resourcePath })
// confirm it exists and is a database kind before introspecting
if (!resource || !isDatabaseKind(resource.resource_type)) { /* fix path/type */ }

Type guard

function isDatabaseResource(r) {
  return r != null && typeof r === 'object' && ['postgresql','mysql','mssql','oracle','snowflake','duckdb','sqlite','clickhouse','mongodb'].includes(r.resource_type)
}

Prevention

When it happens

Trigger: getResource succeeds but the resource is not a database type, the path points to a nonexistent/inaccessible resource in the workspace, or the introspection query produced no schema object.

Common situations: Typo in the resource path; resource lives in another workspace than the chat's; resource is a generic/empty one that the introspection logic cannot classify as a database; permission denies schema read.

Understand the failure class

Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.

Related errors


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