wtfutil/wtf · error

could not write token to disk %w

Error message

could not write token to disk %w

What it means

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.

Source

Thrown at modules/pocket/widget.go:83

		widget.SetItemCount(0)
	}

	widget.items = orderItemResponseByKey(response)
	widget.SetItemCount(len(widget.items))
	widget.Redraw(widget.content)
}

/* -------------------- Unexported Functions -------------------- */

type pocketMetaData struct {
	AccessToken *string
}

func writeMetaDataToDisk(metaData pocketMetaData) error {

	fileData, err := yaml.Marshal(metaData)
	if err != nil {
		return fmt.Errorf("could not write token to disk %w", err)
	}

	wtfConfigDir, err := cfg.WtfConfigDir()

	if err != nil {
		return nil
	}

	filePath := fmt.Sprintf("%s/%s", wtfConfigDir, "pocket.data")
	err = os.WriteFile(filePath, fileData, 0644)

	return err
}

func readMetaDataFromDisk() (pocketMetaData, error) {
	wtfConfigDir, err := cfg.WtfConfigDir()
	var metaData pocketMetaData
	if err != nil {

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Inspect the wrapped error (%w) to identify the serialization failure
  2. Ensure the wtf config directory exists and is writable so the subsequent write can succeed
  3. Re-run the Pocket authorization flow if the stored token metadata is missing or corrupt
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at modules/pocket/widget.go:83 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of wtfutil/wtf@bb838c1ccb (2026-09-03). Data as JSON: /api/errors/6466f379fa85dfba. Report an issue: GitHub.