wavetermdev/waveterm · error
error creating block: %w
Error message
error creating block: %w
What it means
This wraps failures from createBlockObj, which persists the new Block object under the given tab in a store transaction. The %w-wrapped inner error carries the actual reason (tab missing, DB failure, etc.).
Source
Thrown at pkg/wcore/block.go:86
defer func() {
if rtnErr == nil {
return
}
// if there was an error, and we created the block, clean it up since the function failed
if blockCreated && newBlockOID != "" {
deleteBlockObj(ctx, newBlockOID)
filestore.WFS.DeleteZone(ctx, newBlockOID)
}
}()
if blockDef == nil {
return nil, fmt.Errorf("blockDef is nil")
}
if blockDef.Meta == nil || blockDef.Meta.GetString(waveobj.MetaKey_View, "") == "" {
return nil, fmt.Errorf("no view provided for new block")
}
blockData, err := createBlockObj(ctx, tabId, blockDef, rtOpts)
if err != nil {
return nil, fmt.Errorf("error creating block: %w", err)
}
blockCreated = true
newBlockOID = blockData.OID
// upload the files if present
if len(blockDef.Files) > 0 {
for fileName, fileDef := range blockDef.Files {
err := filestore.WFS.MakeFile(ctx, newBlockOID, fileName, fileDef.Meta, wshrpc.FileOpts{})
if err != nil {
return nil, fmt.Errorf("error making blockfile %q: %w", fileName, err)
}
err = filestore.WFS.WriteFile(ctx, newBlockOID, fileName, []byte(fileDef.Content))
if err != nil {
return nil, fmt.Errorf("error writing blockfile %q: %w", fileName, err)
}
}
}
if recordTelemetry {
blockView := blockDef.Meta.GetString(waveobj.MetaKey_View, "")View on GitHub (pinned to a4447c1563)
Solutions
- Read the wrapped inner error for the root cause
- Verify tabId refers to an existing tab (re-fetch if the UI may have closed it)
- Retry after fixing DB-level issues (locks, disk space)
Defensive patterns
Strategy: try-catch
Validate before calling
tab, _ := wstore.DBGet[*waveobj.Tab](ctx, tabId)
if tab == nil { return errors.New("tab missing, aborting block creation") } Try / catch
block, err := wcore.CreateBlock(ctx, tabId, blockDef, rtOpts)
if err != nil {
if strings.Contains(err.Error(), "error creating block") {
// unwrap/log inner cause, optionally retry
}
} Prevention
- Verify the tab exists immediately before creating blocks
- Unwrap errors with errors.Is/As for the root cause
- Watch for DB lock/contention in concurrent block creation
When it happens
Trigger: CreateBlockWithTelemetry called with valid blockDef but createBlockObj fails: nonexistent tabId, database/transaction error, or invalid runtime options.
Common situations: Creating a block against a tab that was just closed; SQLite lock or corruption; invalid RtOpts values rejected during persistence.
Related errors
- error creating sub block: %w
- error updating object: %w
- error getting tab blocks: %w
- parent block not found: %q
- error getting client: %v
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/d23b3f2c9d9bb924.
Report an issue: GitHub.