{"record":{"id":"6466f379fa85dfba","repo":"wtfutil/wtf","slug":"could-not-write-token-to-disk-w","errorCode":null,"errorMessage":"could not write token to disk %w","messagePattern":"could not write token to disk %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"modules/pocket/widget.go","lineNumber":83,"sourceCode":"\t\twidget.SetItemCount(0)\n\t}\n\n\twidget.items = orderItemResponseByKey(response)\n\twidget.SetItemCount(len(widget.items))\n\twidget.Redraw(widget.content)\n}\n\n/* -------------------- Unexported Functions -------------------- */\n\ntype pocketMetaData struct {\n\tAccessToken *string\n}\n\nfunc writeMetaDataToDisk(metaData pocketMetaData) error {\n\n\tfileData, err := yaml.Marshal(metaData)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"could not write token to disk %w\", err)\n\t}\n\n\twtfConfigDir, err := cfg.WtfConfigDir()\n\n\tif err != nil {\n\t\treturn nil\n\t}\n\n\tfilePath := fmt.Sprintf(\"%s/%s\", wtfConfigDir, \"pocket.data\")\n\terr = os.WriteFile(filePath, fileData, 0644)\n\n\treturn err\n}\n\nfunc readMetaDataFromDisk() (pocketMetaData, error) {\n\twtfConfigDir, err := cfg.WtfConfigDir()\n\tvar metaData pocketMetaData\n\tif err != nil {","sourceCodeStart":65,"sourceCodeEnd":101,"githubUrl":"https://github.com/wtfutil/wtf/blob/bb838c1ccb0f0f3223690df44afdec663d622881/modules/pocket/widget.go#L65-L101","documentation":"Raised in writeMetaDataToDisk when yaml.Marshal fails to serialize the Pocket access-token metadata before it is written to pocket.data in the wtf config dir. Marshal of a simple struct rarely fails; the more misleading part is that the error is also produced at this single point even though the actual disk write happens later — check the wrapped error for the real cause.","triggerScenarios":"Thrown at modules/pocket/widget.go:83 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped error (%w) to identify the serialization failure","Ensure the wtf config directory exists and is writable so the subsequent write can succeed","Re-run the Pocket authorization flow if the stored token metadata is missing or corrupt"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"bb838c1ccb0f0f3223690df44afdec663d622881","analyzedAt":"2026-09-03T17:02:45.030Z","contentChangedAt":"2026-09-03T17:02:45.030Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}