{"record":{"id":"93f0701769a13f9c","repo":"wavetermdev/waveterm","slug":"error-getting-block-w-93f070","errorCode":null,"errorMessage":"error getting block: %w","messagePattern":"error getting block: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/blockcontroller/shellcontroller.go","lineNumber":89,"sourceCode":"func MakeShellController(tabId string, blockId string, controllerType string, connName string) Controller {\n\treturn &ShellController{\n\t\tLock:           &sync.Mutex{},\n\t\tControllerType: controllerType,\n\t\tTabId:          tabId,\n\t\tBlockId:        blockId,\n\t\tConnName:       connName,\n\t\tProcStatus:     Status_Init,\n\t\tRunLock:        &atomic.Bool{},\n\t}\n}\n\n// Implement Controller interface methods\n\nfunc (sc *ShellController) Start(ctx context.Context, blockMeta waveobj.MetaMapType, rtOpts *waveobj.RuntimeOpts, force bool) error {\n\t// Get the block data\n\tblockData, err := wstore.DBMustGet[*waveobj.Block](ctx, sc.BlockId)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"error getting block: %w\", err)\n\t}\n\n\t// Use the existing run method which handles all the start logic\n\tgo sc.run(ctx, blockData, blockData.Meta, rtOpts, force)\n\treturn nil\n}\n\nfunc (sc *ShellController) Stop(graceful bool, newStatus string, destroy bool) {\n\tsc.Lock.Lock()\n\tdefer sc.Lock.Unlock()\n\n\tif sc.ShellProc == nil || sc.ProcStatus == Status_Done || sc.ProcStatus == Status_Init {\n\t\tif newStatus != sc.ProcStatus {\n\t\t\tsc.ProcStatus = newStatus\n\t\t\tsc.sendUpdate_nolock()\n\t\t}\n\t\treturn\n\t}","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/blockcontroller/shellcontroller.go#L71-L107","documentation":"ShellController.Start fetches the block record from the wave store (wstore.DBMustGet) before running the shell. If the block cannot be read from the database it cannot be started. This is a local persistence/read failure, independent of any remote connection.","triggerScenarios":"DBMustGet[*waveobj.Block] errors: the BlockId does not exist (block deleted), the store is not initialized, database I/O failure, or the id passed to the controller is stale/incorrect.","commonSituations":"Starting a controller for a block that was closed/deleted concurrently; corrupted or locked local database; calling Start with a fabricated or typo'd block id in tests or plugins.","solutions":["Confirm the BlockId exists (query the block via the store/API) before Start.","Re-create the block/tab if it was deleted; discard the stale controller.","Check the local database health (file permissions, disk space).","Retry after the store finishes initializing at app startup."],"exampleFix":"// before\n_, err := wstore.DBGet[*waveobj.Block](ctx, blockId) // ok == false, still call Start\nerr = sc.Start(ctx, meta, rtOpts, false) // \"error getting block\"\n// after\nif _, err := wstore.DBGet[*waveobj.Block](ctx, sc.BlockId); err != nil {\n    return err // don't attempt Start on a missing block\n}\nreturn sc.Start(ctx, meta, rtOpts, false)","handlingStrategy":"validation","validationCode":"if _, err := wstore.DBGet[*waveobj.Block](ctx, sc.BlockId); err != nil {\n    return fmt.Errorf(\"block %s does not exist, skipping start\", sc.BlockId)\n}","typeGuard":"func blockExists(ctx context.Context, blockId string) bool {\n    _, err := wstore.DBGet[*waveobj.Block](ctx, blockId)\n    return err == nil\n}","tryCatchPattern":"if err := sc.Start(ctx, meta, rtOpts, false); err != nil && strings.Contains(err.Error(), \"error getting block\") {\n    // block is gone; tear down the controller instead of retrying\n    return err\n}","preventionTips":["Verify block existence before constructing a controller","Handle concurrent block deletion events","Keep the local store healthy (disk space, permissions)"],"tags":["database","state","block","lifecycle"],"backgroundTag":"block-not-found","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}