{"record":{"id":"54f5f42e49dee678","repo":"wavetermdev/waveterm","slug":"error-writing-blockfile-q-w","errorCode":null,"errorMessage":"error writing blockfile %q: %w","messagePattern":"error writing blockfile %q: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/wcore/block.go","lineNumber":99,"sourceCode":"\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 := createBlockObj(ctx, tabId, blockDef, rtOpts)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"error creating block: %w\", err)\n\t}\n\tblockCreated = true\n\tnewBlockOID = blockData.OID\n\t// upload the files if present\n\tif len(blockDef.Files) > 0 {\n\t\tfor fileName, fileDef := range blockDef.Files {\n\t\t\terr := filestore.WFS.MakeFile(ctx, newBlockOID, fileName, fileDef.Meta, wshrpc.FileOpts{})\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error making blockfile %q: %w\", fileName, err)\n\t\t\t}\n\t\t\terr = filestore.WFS.WriteFile(ctx, newBlockOID, fileName, []byte(fileDef.Content))\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error writing blockfile %q: %w\", fileName, err)\n\t\t\t}\n\t\t}\n\t}\n\tif recordTelemetry {\n\t\tblockView := blockDef.Meta.GetString(waveobj.MetaKey_View, \"\")\n\t\tblockController := blockDef.Meta.GetString(waveobj.MetaKey_Controller, \"\")\n\t\tgo recordBlockCreationTelemetry(blockView, blockController, false)\n\t}\n\treturn blockData, nil\n}\n\nfunc recordBlockCreationTelemetry(blockView string, blockController string, subBlock bool) {\n\tdefer func() {\n\t\tpanichandler.PanicHandler(\"CreateBlock:telemetry\", recover())\n\t}()\n\tif blockView == \"\" {\n\t\treturn\n\t}","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/wavetermdev/waveterm/blob/a4447c1563b2df285ab89e76c82f91e1a1a49c1e/pkg/wcore/block.go#L81-L117","documentation":"Companion to the MakeFile failure: after successfully creating the blockfile, WFS.WriteFile fails to write the file's byte content. Block creation aborts and the deferred cleanup deletes the block and its file zone.","triggerScenarios":"WFS.WriteFile fails for an entry in blockDef.Files: disk full, I/O error on the storage backend, or the file vanished between MakeFile and WriteFile.","commonSituations":"Large file content exceeding available disk; storage permission problems; concurrent deletion of the block zone during creation.","solutions":["Inspect the wrapped inner error from WFS.WriteFile","Free disk space / fix storage permissions and retry","Reduce the size of inline file content in blockDef.Files, or write content via streaming after block creation"],"exampleFix":"// before\nFiles: map[string]*waveobj.BlockFile{\"big.log\": {Content: hugeString}}\n// after\n// create block without inline content, then stream:\nfilestore.WFS.WriteFile(ctx, blockOID, \"big.log\", contentBytes)","handlingStrategy":"try-catch","validationCode":"if len(fileDef.Content) > maxInlineSize {\n    return errors.New(\"inline blockfile content too large; write after creation\")\n}","typeGuard":null,"tryCatchPattern":"block, err := wcore.CreateBlock(ctx, tabId, blockDef, rtOpts)\nif err != nil && strings.Contains(err.Error(), \"error writing blockfile\") {\n    // check disk/IO, optionally create block then stream content\n}","preventionTips":["Keep inline blockfile content small; stream large files separately","Monitor disk space and storage permissions","Avoid concurrent deletion of a block's file zone during creation"],"tags":["filestore","blocks","io"],"backgroundTag":"file-write-failed","analyzedSha":"a4447c1563b2df285ab89e76c82f91e1a1a49c1e","analyzedAt":"2026-09-01T15:26:23.972Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}