wavetermdev/waveterm · error
no view provided for new block
Error message
no view provided for new block
What it means
CreateSubBlock requires blockDef.Meta to contain a non-empty "view" key (MetaKey_View), which determines what kind of block (terminal, web, preview, etc.) to render. The definition was non-nil but had no view, so Wave cannot know what to instantiate.
Source
Thrown at pkg/wcore/block.go:29
"github.com/google/uuid"
"github.com/wavetermdev/waveterm/pkg/filestore"
"github.com/wavetermdev/waveterm/pkg/panichandler"
"github.com/wavetermdev/waveterm/pkg/telemetry"
"github.com/wavetermdev/waveterm/pkg/telemetry/telemetrydata"
"github.com/wavetermdev/waveterm/pkg/util/utilfn"
"github.com/wavetermdev/waveterm/pkg/waveobj"
"github.com/wavetermdev/waveterm/pkg/wps"
"github.com/wavetermdev/waveterm/pkg/wshrpc"
"github.com/wavetermdev/waveterm/pkg/wstore"
)
func CreateSubBlock(ctx context.Context, blockId string, blockDef *waveobj.BlockDef) (*waveobj.Block, error) {
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 := createSubBlockObj(ctx, blockId, blockDef)
if err != nil {
return nil, fmt.Errorf("error creating sub block: %w", err)
}
blockView := blockDef.Meta.GetString(waveobj.MetaKey_View, "")
blockController := blockDef.Meta.GetString(waveobj.MetaKey_Controller, "")
go recordBlockCreationTelemetry(blockView, blockController, true)
return blockData, nil
}
func createSubBlockObj(ctx context.Context, parentBlockId string, blockDef *waveobj.BlockDef) (*waveobj.Block, error) {
return wstore.WithTxRtn(ctx, func(tx *wstore.TxWrap) (*waveobj.Block, error) {
parentBlock, _ := wstore.DBGet[*waveobj.Block](tx.Context(), parentBlockId)
if parentBlock == nil {
return nil, fmt.Errorf("parent block not found: %q", parentBlockId)
}
blockId := uuid.NewString()View on GitHub (pinned to a4447c1563)
Solutions
- Set blockDef.Meta[waveobj.MetaKey_View] to a valid view type (e.g. "term", "web", "preview")
- Validate the meta map is non-nil and contains the view key before calling CreateSubBlock
- Use meta.ParseBlobFromMap or an existing block's meta as a template to ensure required keys
Example fix
// before
blockDef := &waveobj.BlockDef{} // Meta missing
// after
blockDef := &waveobj.BlockDef{Meta: waveobj.MetaMapType{"view": "term"}} Defensive patterns
Strategy: validation
Validate before calling
if blockDef.Meta == nil || blockDef.Meta.GetString(waveobj.MetaKey_View, "") == "" {
return errors.New("blockDef.Meta must set a non-empty view")
} Type guard
func hasView(d *waveobj.BlockDef) bool {
return d != nil && d.Meta != nil && d.Meta.GetString(waveobj.MetaKey_View, "") != ""
} Try / catch
block, err := wcore.CreateSubBlock(ctx, blockId, blockDef)
if err != nil && strings.Contains(err.Error(), "no view provided") {
// fix meta and retry
} Prevention
- Always set MetaKey_View when building BlockDefs
- Use constants (waveobj.MetaKey_View) rather than raw string keys
- Validate definitions with meta.ParseBlobFromMap before use
When it happens
Trigger: Passing a BlockDef whose Meta is nil, or whose Meta lacks MetaKey_View / sets it to "", via CreateSubBlock or CreateSubBlockCommand.
Common situations: Building block definitions programmatically and forgetting the view field; copying a BlockDef from a layout that stores view elsewhere; typos like "View:" instead of "view:".
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- Image too large (>5MB)
- Unsupported or invalid image type: ${blob.type}
- Invalid CSS color: ${String(color)}
- Invalid CSS color: ${color}
- ai:model is required
AI-assisted analysis of wavetermdev/waveterm@a4447c1563 (2026-09-01).
Data as JSON: /api/errors/16d051e126ae881b.
Report an issue: GitHub.