Skip to content

QueryNodeViewer: getSchema fails with SCHEMA_NOT_FOUND on fresh database #989

Closed

Description

@malibio

Summary

On a fresh database (or after import), the QueryNodeViewer component logs errors when attempting to load schema definitions that don't exist yet:

[Error] [DiagnosticLogger] [ERROR] getSchema (6.00ms)
[Error] [QueryNodeViewer] Failed to load schema node

Root Cause

query-node-viewer.svelte calls backendAdapter.getSchema(schemaId) in loadAndQuery() (line 72). The backend queries SELECT * FROM node:{id} WHERE node_type = 'schema' — on a fresh database without core schema initialization, this returns empty results and the backend returns SCHEMA_NOT_FOUND.

Call chain:

  1. query-node-viewer.svelte → backendAdapter.getSchema(schemaId)
  2. diagnostic-logger.ts → invoke('get_schema_definition', { schemaId })
  3. commands/schemas.rs → service.get_schema_node(&schema_id)
  4. surreal_store.rs → query returns empty → SCHEMA_NOT_FOUND error

Impact

  • Non-critical: the query viewer shows an error state with retry button
  • Noisy console errors on every fresh database load
  • 6ms query duration suggests it's a "not found" rather than connectivity issue

Possible Solutions

  1. Graceful handling: QueryNodeViewer should handle missing schemas without logging an error (e.g., show empty state instead of error)
  2. Core schema initialization: Ensure core schemas (task, date, text) are created on database startup
  3. Lazy schema creation: Create core schemas on first access if they don't exist

Steps to Reproduce

  1. Start the app with a fresh/empty database
  2. Navigate to a schema-driven view (e.g., Tasks)
  3. Observe console errors

Activity

  1. added
    bug
    on Mar 20, 2026
  2. self-assigned this
    on Mar 22, 2026
  3. malibio commented on Mar 22, 2026

    @malibio
    CollaboratorAuthor

    Frontend: 119 test files, 3748 tests passed (baseline)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions