wavetermdev/waveterm · info
ErrNotFound
ErrNotFound
Error message
not found
What it means
ErrNotFound is the sentinel error wstore returns when a queried object does not exist in the database (via DBGet/DBGetORef and friends). Callers should compare with errors.Is(err, wstore.ErrNotFound) to distinguish 'absent' from real failures.
Source
Thrown at pkg/wstore/wstore_dbops.go:20
// SPDX-License-Identifier: Apache-2.0
package wstore
import (
"context"
"fmt"
"log"
"reflect"
"regexp"
"time"
"github.com/wavetermdev/waveterm/pkg/filestore"
"github.com/wavetermdev/waveterm/pkg/panichandler"
"github.com/wavetermdev/waveterm/pkg/util/dbutil"
"github.com/wavetermdev/waveterm/pkg/waveobj"
)
var ErrNotFound = fmt.Errorf("not found")
func waveObjTableName(w waveobj.WaveObj) string {
return "db_" + w.GetOType()
}
func tableNameFromOType(otype string) string {
return "db_" + otype
}
func tableNameGen[T waveobj.WaveObj]() string {
var zeroObj T
return tableNameFromOType(zeroObj.GetOType())
}
func getOTypeGen[T waveobj.WaveObj]() string {
var zeroObj T
return zeroObj.GetOType()
}View on GitHub (pinned to a4447c1563)
Solutions
- Treat it as an expected outcome: use errors.Is(err, wstore.ErrNotFound) to branch instead of failing hard
- Create the object first (DBInsert / the relevant Ensure*/Init* function) before reading it
- Confirm you are pointing at the correct wstore database and the ID was obtained from the same instance
- Re-fetch current IDs instead of caching ones that may have been deleted
Example fix
// before
obj, err := wstore.DBGetORef(ctx, oref)
if err != nil { return err }
// after
obj, err := wstore.DBGetORef(ctx, oref)
if errors.Is(err, wstore.ErrNotFound) {
return createDefault(ctx, oref) // or return nil
}
if err != nil { return err } Defensive patterns
Strategy: try-catch
Validate before calling
obj, _ := wstore.DBGetORef(ctx, oref)
if obj == nil { /* handle absence before calling APIs that expect it */ } Type guard
func isNotFound(err error) bool { return errors.Is(err, wstore.ErrNotFound) } Try / catch
obj, err := wstore.DBGetORef(ctx, oref)
switch {
case errors.Is(err, wstore.ErrNotFound):
// create or default path
return ensureExists(ctx, oref)
case err != nil:
return err
} Prevention
- Compare with errors.Is against wstore.ErrNotFound, never string matching
- Create objects before reading them
- Verify you are on the same database instance that holds the ID
When it happens
Trigger: Calling GetProcInfo/readStat/readUid, EnsureInitialData, InitMainServer, or DeleteWorkspace with an identifier (oid, pid, uid) that has no row in the wstore database.
Common situations: Looking up a process that has already exited; querying a workspace/server that was deleted or not yet initialized; wrong database file (e.g. dev vs prod WAVETERM_HOME) so the expected row is missing.
Understand the failure class
Background: Record Not Found Errors: "not found", RecordNotFound, and "was not found" — what they mean and how to fix them — this error's family across 28 libraries.
Related errors
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/15021fbb05d64212.
Report an issue: GitHub.