wavetermdev/waveterm · error
empty object reference
Error message
empty object reference
What it means
UpdateObjectMeta requires a non-empty waveobj.ORef identifying the object whose metadata should change. An ORef encodes type and ID; an empty one carries no target at all, so the library rejects it up front rather than failing deeper in the transaction.
Source
Thrown at pkg/wstore/wstore.go:60
func UpdateTabName(ctx context.Context, tabId, name string) error {
return WithTx(ctx, func(tx *TxWrap) error {
tab, _ := DBGet[*waveobj.Tab](tx.Context(), tabId)
if tab == nil {
return fmt.Errorf("tab not found: %q", tabId)
}
if tabId != "" {
tab.Name = name
DBUpdate(tx.Context(), tab)
}
return nil
})
}
func UpdateObjectMeta(ctx context.Context, oref waveobj.ORef, meta waveobj.MetaMapType, mergeSpecial bool) error {
return WithTx(ctx, func(tx *TxWrap) error {
if oref.IsEmpty() {
return fmt.Errorf("empty object reference")
}
obj, _ := DBGetORef(tx.Context(), oref)
if obj == nil {
return ErrNotFound
}
objMeta := waveobj.GetMeta(obj)
if objMeta == nil {
objMeta = make(map[string]any)
}
newMeta := waveobj.MergeMeta(objMeta, meta, mergeSpecial)
waveobj.SetMeta(obj, newMeta)
DBUpdate(tx.Context(), obj)
return nil
})
}
View on GitHub (pinned to a4447c1563)
Solutions
- Check oref.IsEmpty() at the call site and skip or fix the caller that produced the empty reference
- Validate the source string with waveobj.ParseORef and handle its error instead of discarding it
- Ensure the object field carrying the ORef is populated before invoking meta updates
Example fix
// before
wstore.UpdateObjectMeta(ctx, oref, meta, true) // oref may be zero
// after
if oref.IsEmpty() {
return nil
}
wstore.UpdateObjectMeta(ctx, oref, meta, true) Defensive patterns
Strategy: validation
Validate before calling
if oref.IsEmpty() {
return fmt.Errorf("no target object for meta update")
} Type guard
func hasORef(oref waveobj.ORef) bool { return !oref.IsEmpty() } Try / catch
if err := wstore.UpdateObjectMeta(ctx, oref, meta, true); err != nil {
if strings.Contains(err.Error(), "empty object reference") {
return populateORefAndRetry()
}
return err
} Prevention
- Always build ORefs via waveobj.ParseORef and check its error
- Never use the zero-value ORef struct
- Validate refs at API boundaries
When it happens
Trigger: Passing the zero value of waveobj.ORef (e.g. ORef{} from an unpopulated struct or a failed ParseORef whose error was ignored) into wstore.UpdateObjectMeta.
Common situations: Constructing an ORef from an empty oref string field on a partially initialized object; ignoring the error from waveobj.ParseORef and using the zero ORef; default-struct fields never assigned before a meta update.
Related errors
- badge oref must be a block or tab (got %q)
- invalid object reference: %q
- error parsing object reference: %w
- invalid oref string: %v
- cannot convert %T to %s (idx %d) error: %v
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/77960f4cfbbbfd8a.
Report an issue: GitHub.