wavetermdev/waveterm · error

invalid oref string

Error message

invalid oref string: %v

What it means

Returned when a string cannot be parsed as a valid oref (object reference), such as malformed syntax or an unknown reference format. The offending input is included via %v for diagnostics.

Solutions

  1. Read the wrapped cause for the exact parse failure.
  2. Trim whitespace and verify the OID matches the expected Wave OID format.
  3. Re-fetch the identifier from the backend instead of reconstructing it manually.

Example fix

// before
oref, err := waveobj.ParseORef("  " + oid + ":")
// after
oref, err := waveobj.ParseORef(strings.TrimSpace(oid))
if err != nil {
    return fmt.Errorf("bad oid %q: %v", oid, err)
}
Defensive patterns

Strategy: validation

Validate before calling

oid = strings.TrimSpace(oid)
if oid == "" {
    return fmt.Errorf("empty oref")
}
if _, err := waveobj.ParseORef(oid); err != nil {
    return fmt.Errorf("bad oref %q: %v", oid, err)
}

Try / catch

_, err := waveobj.ParseORef(s)
if err != nil {
    return fmt.Errorf("invalid oref %q: %w", s, err)
}

Prevention

When it happens

Trigger: Passing a malformed OID string to an ORef parameter - wrong length/charset, empty string, or a 'type:oid' composite with an unknown type prefix.

Common situations: Truncated or whitespace-contaminated OIDs copied from logs; OIDs mangled by URL decoding; type and ID concatenated with the wrong separator.

Understand the failure class

Background: "invalid id" errors: invalid identifier format — why libraries reject IDs before lookup, and how to fix them — this error's family across 37 libraries.

Related errors


AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01). Data as JSON: /api/errors/a29a968541ee1174. Report an issue: GitHub.

Appendix: source

Thrown at pkg/service/service.go:121

	if _, ok := jsonArg.(map[string]any); !ok {
		return nil, fmt.Errorf("cannot convert %T to %s", jsonArg, argType)
	}
	cmd, err := webcmd.ParseWSCommandMap(jsonArg.(map[string]any))
	if err != nil {
		return nil, fmt.Errorf("error parsing command map: %w", err)
	}
	return cmd, nil
}

func convertSpecial(argType reflect.Type, jsonArg any) (any, error) {
	jsonType := reflect.TypeOf(jsonArg)
	if argType == orefRType {
		if jsonType.Kind() != reflect.String {
			return nil, fmt.Errorf("cannot convert %T to %s", jsonArg, argType)
		}
		oref, err := waveobj.ParseORef(jsonArg.(string))
		if err != nil {
			return nil, fmt.Errorf("invalid oref string: %v", err)
		}
		return oref, nil
	} else if argType == wsCommandRType {
		return convertWSCommand(argType, jsonArg)
	} else if argType == waveObjRType {
		if jsonType.Kind() != reflect.Map {
			return nil, fmt.Errorf("cannot convert %T to %s", jsonArg, argType)
		}
		return waveobj.FromJsonMap(jsonArg.(map[string]any))
	} else if argType == waveObjSliceRType {
		if jsonType.Kind() != reflect.Slice {
			return nil, fmt.Errorf("cannot convert %T to %s", jsonArg, argType)
		}
		sliceArg := jsonArg.([]any)
		nativeSlice := make([]waveobj.WaveObj, len(sliceArg))
		for idx, elem := range sliceArg {
			elemMap, ok := elem.(map[string]any)
			if !ok {

View on GitHub (pinned to a4447c1563)