wtfutil/wtf · error

client was not initialized

Error message

client was not initialized

What it means

The transmission widget's Fetch method returns this error when widget.client is nil, i.e. the Transmission RPC client was never initialized (normally done in the widget constructor by connecting to the Transmission daemon). Fetch refuses to proceed rather than panic on a nil client.

Source

Thrown at modules/transmission/widget.go:45

		ScrollableWidget: view.NewScrollableWidget(tviewApp, redrawChan, pages, settings.Common),

		settings: settings,
	}

	widget.SetRenderFunction(widget.display)
	widget.initializeKeyboardControls()

	go buildClient(&widget)

	return &widget
}

/* -------------------- Exported Functions -------------------- */

// Fetch retrieves torrent data from the Transmission daemon
func (widget *Widget) Fetch() ([]transmissionrpc.Torrent, error) {
	if widget.client == nil {
		return nil, errors.New("client was not initialized")
	}

	torrents, err := widget.client.TorrentGetAll(context.Background())
	if err != nil {
		return nil, err
	}

	out := make([]transmissionrpc.Torrent, 0)
	for _, torrent := range torrents {
		if widget.settings.hideComplete {
			if *torrent.PercentDone == 1.0 {
				continue
			}
		}

		out = append(out, torrent)
	}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Start the Transmission daemon and confirm it is listening (default http://localhost:9091/transmission/rpc).
  2. Check the transmission module settings in the WTFUtil config: correct URL, port, username, and password.
  3. If the daemon enforces rpc-whitelist or rpc-authentication-required, allow your host or supply credentials.
  4. Restart WTFUtil after fixing settings so the widget constructor re-initializes the client.

Example fix

// before (config.yml)
transmission:
  url: "http://localhost:9091"  # missing /transmission/rpc path

// after
transmission:
  url: "http://localhost:9091/transmission/rpc"
  username: "user"
  password: "pass"
Defensive patterns

Strategy: validation

Validate before calling

resp, err := http.Get("http://localhost:9091/transmission/rpc")
if err != nil {
    return errors.New("Transmission daemon unreachable; client will be nil")
}
if resp != nil && resp.Body != nil {
    resp.Body.Close()
}

Try / catch

torrents, err := widget.Fetch()
if err != nil && err.Error() == "client was not initialized" {
    // re-create widget / fix daemon connection before retrying
}

Prevention

When it happens

Trigger: Calling widget.Fetch() (directly or via Refresh) when the constructor failed to create the RPC client — typically because the Transmission daemon was unreachable, the RPC URL/credentials in the module settings are wrong, or NewClient errored at startup.

Common situations: Transmission daemon not running or listening on a different port than configured; wrong rpc-url, username, or password in the WTFUtil config; daemon's rpc-whitelist rejecting the host; token/auth handshake failing so client creation silently yields nil.

Related errors


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