{"record":{"id":"5967ba688b84ee55","repo":"wavetermdev/waveterm","slug":"error-deleting-block-w","errorCode":null,"errorMessage":"error deleting block: %w","messagePattern":"error deleting block: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/service/objectservice/objectservice.go","lineNumber":110,"sourceCode":"\t\treturn \"\", nil, err\n\t}\n\n\treturn blockData.OID, waveobj.ContextGetUpdatesRtn(ctx), nil\n}\n\nfunc (svc *ObjectService) DeleteBlock_Meta() tsgenmeta.MethodMeta {\n\treturn tsgenmeta.MethodMeta{\n\t\tArgNames: []string{\"uiContext\", \"blockId\"},\n\t}\n}\n\nfunc (svc *ObjectService) DeleteBlock(uiContext waveobj.UIContext, blockId string) (waveobj.UpdatesRtnType, error) {\n\tctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)\n\tdefer cancelFn()\n\tctx = waveobj.ContextWithUpdates(ctx)\n\terr := wcore.DeleteBlock(ctx, blockId, true)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error deleting block: %w\", err)\n\t}\n\treturn waveobj.ContextGetUpdatesRtn(ctx), nil\n}\n\nfunc (svc *ObjectService) UpdateObjectMeta_Meta() tsgenmeta.MethodMeta {\n\treturn tsgenmeta.MethodMeta{\n\t\tArgNames: []string{\"uiContext\", \"oref\", \"meta\"},\n\t}\n}\n\nfunc (svc *ObjectService) UpdateObjectMeta(uiContext waveobj.UIContext, orefStr string, meta waveobj.MetaMapType) (waveobj.UpdatesRtnType, error) {\n\tctx, cancelFn := context.WithTimeout(context.Background(), DefaultTimeout)\n\tdefer cancelFn()\n\tctx = waveobj.ContextWithUpdates(ctx)\n\toref, err := parseORef(orefStr)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error parsing object reference: %w\", err)\n\t}","sourceCodeStart":92,"sourceCodeEnd":128,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/service/objectservice/objectservice.go#L92-L128","documentation":"DeleteBlock wraps failures from wcore.DeleteBlock(ctx, blockId, true) with 'error deleting block: %w'. The block removal failed in the core layer — typically the blockId does not exist, or cascading cleanup of the block's children/refs failed.","triggerScenarios":"Calling ObjectService.DeleteBlock with an already-deleted or never-existing blockId, or when the underlying tab/layout update fails during cascade delete.","commonSituations":"Double-invoking a close action on the same block; deleting from a stale UI list after another window closed the block; id mix-ups (passing tabId as blockId).","solutions":["Check the wrapped error: 'key not found' means the block is already gone — treat the delete as idempotent success","Refresh the block list before retrying the delete","Verify the id is a block id (OType 'block'), not another object type"],"exampleFix":"// before\n_, err := svc.DeleteBlock(uiContext, blockId)\n// after\nif _, err := svc.DeleteBlock(uiContext, blockId); err != nil && strings.Contains(err.Error(), \"key not found\") {\n    // already deleted; continue\n    return nil\n}","handlingStrategy":"try-catch","validationCode":"if blockId == \"\" { return fmt.Errorf(\"blockId required\") }","typeGuard":null,"tryCatchPattern":"_, err := svc.DeleteBlock(uiContext, blockId)\nif err != nil {\n    if strings.Contains(err.Error(), \"key not found\") { return nil } // already gone\n    return err\n}","preventionTips":["Treat block deletion as idempotent","Refresh UI block lists after deletes to avoid stale ids","Confirm the id is a block id, not a tab/window id"],"tags":["go","blocks","delete","wcore"],"backgroundTag":"record-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}