wavetermdev/waveterm · error

resolving -r blockid: %w

Error message

resolving -r blockid: %w

What it means

webOpenRun resolves the -r/--replace blockid argument with resolveSimpleId before opening the URL. If that id cannot be parsed or resolved into an ORef, the failure is wrapped with "resolving -r blockid:".

Source

Thrown at cmd/wsh/cmd/wshcmd-web.go:108

	} else {
		for _, item := range output {
			WriteStdout("%s\n", item)
		}
	}
	return nil
}

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

	var replaceBlockORef *waveobj.ORef
	if webOpenReplaceBlock != "" {
		var err error
		replaceBlockORef, err = resolveSimpleId(webOpenReplaceBlock)
		if err != nil {
			return fmt.Errorf("resolving -r blockid: %w", err)
		}
	}
	if replaceBlockORef != nil && webOpenMagnified {
		return fmt.Errorf("cannot use --replace and --magnified together")
	}

	tabId := getTabIdFromEnv()
	if tabId == "" {
		return fmt.Errorf("no WAVETERM_TABID env var set")
	}

	wshCmd := wshrpc.CommandCreateBlockData{
		TabId: tabId,
		BlockDef: &waveobj.BlockDef{
			Meta: map[string]any{
				waveobj.MetaKey_View: "web",
				waveobj.MetaKey_Url:  args[0],
			},

View on GitHub (pinned to a4447c1563)

Solutions

  1. Verify the block id via `wsh ls` and pass the full valid OID
  2. Omit --replace to create a brand-new block instead of replacing one
  3. Ensure the target block is still open in the connected Wave session

Example fix

// before
wsh web open https://example.com --replace 1234
// after
wsh web open https://example.com --replace <full-valid-block-oid>
Defensive patterns

Strategy: validation

Validate before calling

if webOpenReplaceBlock != "" {
    if _, err := resolveSimpleId(webOpenReplaceBlock); err != nil {
        return fmt.Errorf("invalid --replace blockid: %w", err)
    }
}

Type guard

func isValidBlockId(id string) bool {
    _, err := resolveSimpleId(id)
    return err == nil
}

Prevention

When it happens

Trigger: `wsh web open <url> --replace <bad-id>` where the id is empty-formatted, not a valid OID or block id, or refers to a nonexistent block.

Common situations: Typo in the block id; passing a tab id instead of a block id; stale id from a closed block.

Related errors


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