{"record":{"id":"16d051e126ae881b","repo":"wavetermdev/waveterm","slug":"no-view-provided-for-new-block","errorCode":null,"errorMessage":"no view provided for new block","messagePattern":"no view provided for new block","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wcore/block.go","lineNumber":29,"sourceCode":"\n\t\"github.com/google/uuid\"\n\t\"github.com/wavetermdev/waveterm/pkg/filestore\"\n\t\"github.com/wavetermdev/waveterm/pkg/panichandler\"\n\t\"github.com/wavetermdev/waveterm/pkg/telemetry\"\n\t\"github.com/wavetermdev/waveterm/pkg/telemetry/telemetrydata\"\n\t\"github.com/wavetermdev/waveterm/pkg/util/utilfn\"\n\t\"github.com/wavetermdev/waveterm/pkg/waveobj\"\n\t\"github.com/wavetermdev/waveterm/pkg/wps\"\n\t\"github.com/wavetermdev/waveterm/pkg/wshrpc\"\n\t\"github.com/wavetermdev/waveterm/pkg/wstore\"\n)\n\nfunc CreateSubBlock(ctx context.Context, blockId string, blockDef *waveobj.BlockDef) (*waveobj.Block, error) {\n\tif blockDef == nil {\n\t\treturn nil, fmt.Errorf(\"blockDef is nil\")\n\t}\n\tif blockDef.Meta == nil || blockDef.Meta.GetString(waveobj.MetaKey_View, \"\") == \"\" {\n\t\treturn nil, fmt.Errorf(\"no view provided for new block\")\n\t}\n\tblockData, err := createSubBlockObj(ctx, blockId, blockDef)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating sub block: %w\", err)\n\t}\n\tblockView := blockDef.Meta.GetString(waveobj.MetaKey_View, \"\")\n\tblockController := blockDef.Meta.GetString(waveobj.MetaKey_Controller, \"\")\n\tgo recordBlockCreationTelemetry(blockView, blockController, true)\n\treturn blockData, nil\n}\n\nfunc createSubBlockObj(ctx context.Context, parentBlockId string, blockDef *waveobj.BlockDef) (*waveobj.Block, error) {\n\treturn wstore.WithTxRtn(ctx, func(tx *wstore.TxWrap) (*waveobj.Block, error) {\n\t\tparentBlock, _ := wstore.DBGet[*waveobj.Block](tx.Context(), parentBlockId)\n\t\tif parentBlock == nil {\n\t\t\treturn nil, fmt.Errorf(\"parent block not found: %q\", parentBlockId)\n\t\t}\n\t\tblockId := uuid.NewString()","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/block.go#L11-L47","documentation":"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.","triggerScenarios":"Passing a BlockDef whose Meta is nil, or whose Meta lacks MetaKey_View / sets it to \"\", via CreateSubBlock or CreateSubBlockCommand.","commonSituations":"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:\".","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"],"exampleFix":"// before\nblockDef := &waveobj.BlockDef{} // Meta missing\n// after\nblockDef := &waveobj.BlockDef{Meta: waveobj.MetaMapType{\"view\": \"term\"}}","handlingStrategy":"validation","validationCode":"if blockDef.Meta == nil || blockDef.Meta.GetString(waveobj.MetaKey_View, \"\") == \"\" {\n    return errors.New(\"blockDef.Meta must set a non-empty view\")\n}","typeGuard":"func hasView(d *waveobj.BlockDef) bool {\n    return d != nil && d.Meta != nil && d.Meta.GetString(waveobj.MetaKey_View, \"\") != \"\"\n}","tryCatchPattern":"block, err := wcore.CreateSubBlock(ctx, blockId, blockDef)\nif err != nil && strings.Contains(err.Error(), \"no view provided\") {\n    // fix meta and retry\n}","preventionTips":["Always set MetaKey_View when building BlockDefs","Use constants (waveobj.MetaKey_View) rather than raw string keys","Validate definitions with meta.ParseBlobFromMap before use"],"tags":["validation","blocks","metadata"],"backgroundTag":"missing-required-argument","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}