wavetermdev/waveterm · error

badge oref must be a block or tab (got %q)

Error message

badge oref must be a block or tab (got %q)

What it means

After resolving, badgeRun validates that the resolved oref is a block or a tab, since badges attach to those object types. Any other resolved type (e.g. a window or workspace reference) triggers this error showing the actual type.

Source

Thrown at cmd/wsh/cmd/wshcmd-badge.go:62

func badgeRun(cmd *cobra.Command, args []string) (rtnErr error) {
	defer func() {
		sendActivity("badge", rtnErr == nil)
	}()

	if badgePid > 0 && runtime.GOOS == "windows" {
		return fmt.Errorf("--pid flag is not supported on Windows")
	}
	if badgePid > 0 && !cmd.Flags().Changed("priority") {
		badgePriority = 5
	}

	oref, err := resolveBlockArg()
	if err != nil {
		return fmt.Errorf("resolving block: %v", err)
	}
	if oref.OType != waveobj.OType_Block && oref.OType != waveobj.OType_Tab {
		return fmt.Errorf("badge oref must be a block or tab (got %q)", oref.OType)
	}

	var eventData baseds.BadgeEvent
	eventData.ORef = oref.String()

	if badgeClear {
		eventData.Clear = true
	} else {
		icon := "circle-small"
		if len(args) > 0 {
			icon = args[0]
		}
		badgeId, err := uuid.NewV7()
		if err != nil {
			return fmt.Errorf("generating badge id: %v", err)
		}
		eventData.Badge = &baseds.Badge{
			BadgeId:   badgeId.String(),

View on GitHub (pinned to a4447c1563)

Solutions

  1. Pass a block or tab reference: verify the oref prefix is `block:` or `tab:`.
  2. Re-copy the oref from the target block/tab in Wave Terminal.
  3. Adjust scripts to filter to block/tab types before calling wsh badge.

Example fix

// before
wsh badge workspace:abc "info"  # badge oref must be a block or tab (got "workspace")

// after
wsh badge block:def456 "info"
Defensive patterns

Strategy: validation

Validate before calling

if !strings.HasPrefix(orefStr, "block:") && !strings.HasPrefix(orefStr, "tab:") {
    // reject before calling wsh badge
}

Type guard

func isBlockOrTabORef(o waveobj.ORef) bool {
    return o.OType == waveobj.OType_Block || o.OType == waveobj.OType_Tab
}

Prevention

When it happens

Trigger: Passing a reference that resolves to a non-block/non-tab Wave object — for example a workspace or window oref — to `wsh badge`.

Common situations: Copy-pasting an oref of the wrong type (workspace instead of block); scripting that blindly forwards a generic oref variable into the badge command.

Related errors


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