{"record":{"id":"322d46c63ef87109","repo":"windmill-labs/windmill","slug":"database-not-found","errorCode":null,"errorMessage":"Database not found","messagePattern":"Database not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"frontend/src/lib/components/copilot/chat/script/core.ts","lineNumber":496,"sourceCode":"\t\t\t\tthrow new Error('Database path not provided')\n\t\t\t}\n\t\t\ttoolCallbacks.setToolStatus(toolId, {\n\t\t\t\tcontent: 'Getting database schema for ' + args.resourcePath + '...'\n\t\t\t})\n\t\t\tconst resource = await ResourceService.getResource({\n\t\t\t\tworkspace: workspace,\n\t\t\t\tpath: args.resourcePath\n\t\t\t})\n\t\t\tconst dbSchema = await getDbSchemas(\n\t\t\t\tresource.resource_type,\n\t\t\t\targs.resourcePath,\n\t\t\t\tworkspace,\n\t\t\t\t(error) => {\n\t\t\t\t\tconsole.error(error)\n\t\t\t\t}\n\t\t\t)\n\t\t\tif (!dbSchema) {\n\t\t\t\tthrow new Error('Database not found')\n\t\t\t}\n\t\t\t// The dbSchemas store is an editor cache keyed by resource path with no\n\t\t\t// workspace dimension: a chat that may operate on a different workspace than\n\t\t\t// the navigation one (global/session) must not write into it.\n\t\t\tif (updateEditorCache) {\n\t\t\t\tdbSchemas.update((schemas) => ({ ...schemas, [args.resourcePath]: dbSchema }))\n\t\t\t}\n\t\t\tconst stringSchema = await formatDBSchema(dbSchema)\n\t\t\ttoolCallbacks.setToolStatus(toolId, {\n\t\t\t\tcontent: 'Retrieved database schema for ' + args.resourcePath\n\t\t\t})\n\t\t\treturn stringSchema\n\t\t}\n\t}\n}\n\nexport const dbSchemaTool: Tool<ScriptChatHelpers> = createDbSchemaTool<ScriptChatHelpers>()\n","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/windmill-labs/windmill/blob/e474e8803ce2ff5c2df09a58dab51d45f5c922ca/frontend/src/lib/components/copilot/chat/script/core.ts#L478-L514","documentation":"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'.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Confirm the resource path exists in the current workspace (resource list or /resources page)","Check the resource is a database kind (postgresql, mysql, etc.) the tool supports","Verify workspace/permissions: the chat workspace must be able to read the resource","Fix the resource's configuration (connection string/fields) so introspection can run"],"exampleFix":"// before\n{ resourcePath: 'u/admin/marekting_db' } // typo -> 'Database not found'\n// after\n{ resourcePath: 'u/admin/marketing_db' }","handlingStrategy":"validation","validationCode":"const resource = await ResourceService.getResource({ workspace, path: resourcePath })\n// confirm it exists and is a database kind before introspecting\nif (!resource || !isDatabaseKind(resource.resource_type)) { /* fix path/type */ }","typeGuard":"function isDatabaseResource(r) {\n  return r != null && typeof r === 'object' && ['postgresql','mysql','mssql','oracle','snowflake','duckdb','sqlite','clickhouse','mongodb'].includes(r.resource_type)\n}","tryCatchPattern":null,"preventionTips":["Verify the resource path in the /resources page of the chat's workspace","Ensure the resource type is one the schema tool supports","Check read permissions on the resource before introspection"],"tags":["database","resource","ai-copilot","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"e474e8803ce2ff5c2df09a58dab51d45f5c922ca","analyzedAt":"2026-09-03T12:38:19.024Z","contentChangedAt":"2026-09-03T12:38:19.024Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}