{"record":{"id":"ca6aa3a2e1ee4b13","repo":"charmbracelet/glow","slug":"could-not-load-file-missing-path","errorCode":null,"errorMessage":"could not load file: missing path","messagePattern":"could not load file: missing path","errorType":"console","errorClass":"errMsg","httpStatus":null,"severity":"error","filePath":"ui/stash.go","lineNumber":844,"sourceCode":"\tif itemsOnPage < m.paginator().PerPage {\n\t\tn := (m.paginator().PerPage - itemsOnPage) * stashViewItemHeight\n\t\tif len(mds) == 0 {\n\t\t\tn -= stashViewItemHeight - 1\n\t\t}\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfmt.Fprint(&b, \"\\n\")\n\t\t}\n\t}\n\n\treturn b.String()\n}\n\n// COMMANDS\n\nfunc loadLocalMarkdown(md *markdown) tea.Cmd {\n\treturn func() tea.Msg {\n\t\tif md.localPath == \"\" {\n\t\t\treturn errMsg{errors.New(\"could not load file: missing path\")}\n\t\t}\n\n\t\tdata, err := os.ReadFile(md.localPath)\n\t\tif err != nil {\n\t\t\tlog.Debug(\"error reading local file\", \"error\", err)\n\t\t\treturn errMsg{err}\n\t\t}\n\t\tmd.Body = string(data)\n\t\treturn fetchedMarkdownMsg(md)\n\t}\n}\n\nfunc filterMarkdowns(m stashModel) tea.Cmd {\n\treturn func() tea.Msg {\n\t\tif m.filterInput.Value() == \"\" || !m.filterApplied() {\n\t\t\treturn filteredMarkdownMsg(m.markdowns) // return everything\n\t\t}\n","sourceCodeStart":826,"sourceCodeEnd":862,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/ui/stash.go#L826-L862","documentation":"loadLocalMarkdown is a bubbletea Cmd used by the stash/pager to read a document from disk into md.Body. If the markdown struct's localPath is the empty string, there is nothing to os.ReadFile, so it immediately returns this errMsg. Documents that come from the network or are constructed without a path have localPath == \"\".","triggerScenarios":"Opening a markdown item in the TUI whose localPath was never set (e.g., a news/stash item fetched from the network rather than a local file); a document struct built with only a URL; triggering a reload (pager key or file-watch event) after the path field was lost.","commonSituations":"Using the stash UI on remote/Glow-hosted docs and hitting the local-load path; opening the pager on a doc created from stdin where no filename exists; stale state after a failed load.","solutions":["Open the document from the local filesystem (file picker or glow <path>) so localPath is populated","For remote/stashed docs, use the fetch-from-stash command path instead of the local loader","If embedding glow's UI, always construct markdown with a non-empty localPath before triggering a reload"],"exampleFix":"// ui/ui.go — local documents get a path\nmd := &markdown{localPath: path}\n\n// before (path missing)\nmd := &markdown{}\ncmd := loadLocalMarkdown(md) // errMsg: could not load file: missing path\n\n// after\nmd := &markdown{localPath: \"/tmp/errlookup-LwPSGd/README.md\"}\ncmd := loadLocalMarkdown(md)","handlingStrategy":"type-guard","validationCode":"// before issuing loadLocalMarkdown, make sure a path exists\nif md.localPath == \"\" {\n\tmd.localPath = pickFileWithPicker() // or refuse the action\n\tif md.localPath == \"\" {\n\t\treturn nil // do not dispatch the load command at all\n\t}\n}","typeGuard":"// hasLocalSource reports whether md can be loaded from disk\n// (ui/markdown.go keeps the path in the unexported localPath field).\nfunc hasLocalSource(md *markdown) bool {\n\treturn md != nil && md.localPath != \"\"\n}\n\nif !hasLocalSource(md) {\n\treturn tea.Quit // or route to the network fetch command instead\n}\ncmd := loadLocalMarkdown(md)","tryCatchPattern":"// errMsg arrives as a tea.Msg in Update:\nswitch msg := msg.(type) {\ncase errMsg:\n\tif strings.Contains(msg.err.Error(), \"missing path\") {\n\t\t// document has no backing file; refresh state or switch source\n\t\treturn m, fetchFromStashCmd(m.currentDocument)\n\t}\n\tm.err = msg\n\treturn m, tea.Quit\n}","preventionTips":["Always populate localPath when constructing markdown values that will be reloaded (as ui/ui.go:152 does for local files)","Treat empty localPath as 'remote-only document' and dispatch the stash/network fetch command instead","Do not wire file-watch reloads to documents you did not open from disk"],"tags":["tui","bubbletea","file","stash","state"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}