{"record":{"id":"a37a0caaf5e3a389","repo":"wavetermdev/waveterm","slug":"object-reference-is-not-a-block","errorCode":null,"errorMessage":"object reference is not a block","messagePattern":"object reference is not a block","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cmd/wsh/cmd/wshcmd-deleteblock.go","lineNumber":40,"sourceCode":"\nfunc init() {\n\trootCmd.AddCommand(deleteBlockCmd)\n}\n\nfunc deleteBlockRun(cmd *cobra.Command, args []string) (rtnErr error) {\n\tdefer func() {\n\t\tsendActivity(\"deleteblock\", rtnErr == nil)\n\t}()\n\tvar blockRef string\n\tif len(args) > 0 {\n\t\tblockRef = args[0]\n\t}\n\tfullORef, err := resolveBlockArgWithOverride(blockRef)\n\tif err != nil {\n\t\treturn err\n\t}\n\tif fullORef.OType != \"block\" {\n\t\treturn fmt.Errorf(\"object reference is not a block\")\n\t}\n\tdeleteBlockData := &wshrpc.CommandDeleteBlockData{\n\t\tBlockId: fullORef.OID,\n\t}\n\terr = wshclient.DeleteBlockCommand(RpcClient, *deleteBlockData, &wshrpc.RpcOpts{Timeout: 2000})\n\tif err != nil {\n\t\treturn fmt.Errorf(\"delete block failed: %v\", err)\n\t}\n\tWriteStdout(\"block deleted\\n\")\n\treturn nil\n}\n","sourceCodeStart":22,"sourceCodeEnd":52,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/cmd/wsh/cmd/wshcmd-deleteblock.go#L22-L52","documentation":"deleteBlockRun resolves the block argument to a full object reference and requires its OType to be exactly \"block\". If the reference resolves to another object type (file, job, applet, etc.), the command refuses to delete it and returns this error before issuing the DeleteBlockCommand RPC.","triggerScenarios":"Calling `wsh deleteblock` with a reference (OID or name) that resolves to a non-block object, e.g. a file or job object.","commonSituations":"Passing a file OID instead of a terminal/preview block id; using a bookmark or object name that shadows a non-block object; copying the wrong OID from block info.","solutions":["Verify the object type with `wsh obj` or block info before deleting","Pass the OID of an actual block (terminal, preview, etc.)","Re-run with the correct block id from `wsh ls` / getblocks"],"exampleFix":"// before\nwsh deleteblock <file-oid>\n// after\nwsh deleteblock <block-oid>","handlingStrategy":"type-guard","validationCode":"oref, err := wshclient.ResolveBlockCommand(rpc, blockId, nil)\nif err != nil || oref.OType != \"block\" {\n    return fmt.Errorf(\"%s is not a block\", blockId)\n}","typeGuard":"func isBlockRef(oref waveobj.ORef) bool {\n    return oref.OType == \"block\"\n}","tryCatchPattern":"if err := runDeleteBlock(ref); err != nil {\n    if strings.Contains(err.Error(), \"object reference is not a block\") {\n        // resolve the actual block id and retry\n    }\n}","preventionTips":["Copy block OIDs from `wsh ls`/block info, not file listings","Check OType before passing any ORef to block commands","Don't confuse file objects with blocks in scripts"],"tags":["cli","validation","block"],"backgroundTag":"wrong-object-type","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}