wavetermdev/waveterm · error
invalid object reference: %q
Error message
invalid object reference: %q
What it means
parseORef rejects any string that does not split on ':' into exactly two fields, returning 'invalid object reference: %q'. An ORef must be 'type:oid' (e.g. 'block:xxx'). This is a client-side argument validation error thrown before any DB access, and it propagates through GetObject, GetObjects, and UpdateObjectMeta.
Source
Thrown at pkg/service/objectservice/objectservice.go:27
"strings"
"time"
"github.com/wavetermdev/waveterm/pkg/tsgen/tsgenmeta"
"github.com/wavetermdev/waveterm/pkg/waveobj"
"github.com/wavetermdev/waveterm/pkg/wcore"
"github.com/wavetermdev/waveterm/pkg/wps"
"github.com/wavetermdev/waveterm/pkg/wstore"
)
type ObjectService struct{}
const DefaultTimeout = 2 * time.Second
const ConnContextTimeout = 60 * time.Second
func parseORef(oref string) (*waveobj.ORef, error) {
fields := strings.Split(oref, ":")
if len(fields) != 2 {
return nil, fmt.Errorf("invalid object reference: %q", oref)
}
return &waveobj.ORef{OType: fields[0], OID: fields[1]}, nil
}
func (svc *ObjectService) GetObject_Meta() tsgenmeta.MethodMeta {
return tsgenmeta.MethodMeta{
Desc: "get wave object by oref",
ArgNames: []string{"oref"},
}
}
func (svc *ObjectService) GetObject(orefStr string) (waveobj.WaveObj, error) {
oref, err := parseORef(orefStr)
if err != nil {
return nil, err
}
ctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)
defer cancelFn()View on GitHub (pinned to a4447c1563)
Solutions
- Ensure the string is exactly 'type:oid' with a single ':' (e.g. 'block:B123')
- Strip any scheme/prefix decoration before passing
- Build refs programmatically with waveobj.ORef{OType, OID}.String() instead of string concatenation
Example fix
// before
obj, err := svc.GetObject(ctx, "block:B123:extra")
// after
obj, err := svc.GetObject(ctx, (waveobj.ORef{OType: "block", OID: "B123"}).String()) Defensive patterns
Strategy: validation
Validate before calling
func validORef(s string) bool {
parts := strings.Split(s, ":")
return len(parts) == 2 && parts[0] != "" && parts[1] != ""
}
if !validORef(orefStr) { return fmt.Errorf("bad oref %q", orefStr) } Type guard
func isORef(s string) bool { return len(strings.Split(s, ":")) == 2 } Try / catch
oref, err := parseORef(input)
if err != nil {
return fmt.Errorf("bad ref %q: %w", input, err)
} Prevention
- Always build orefs via ORef.String() helpers, not concatenation
- Strip URI schemes/prefixes before passing refs
- Keep type prefix and OID ordering consistent ('type:oid')
When it happens
Trigger: Passing an oref with zero or multiple colons, an empty string, a bare OID without the type prefix, or a full URI with extra ':' segments (e.g. 'wave://block:id').
Common situations: Constructing ORefs by hand instead of via waveobj.ORef helpers; storing/logging orefs with added prefixes; copy-pasting identifiers from logs that include scheme prefixes.
Related errors
- invalid format of user@host argument
- error parsing object reference: %w
- invalid oref string: %v
- invalid data URL: must start with 'data:'
- oref is required
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/df7406461cb9b5ef.
Report an issue: GitHub.