wtfutil/wtf · error

errors.New(response.ErrorMessage)

Error message

errors.New(response.ErrorMessage)

What it means

This is not a fixed message: the Twitch widget dynamically builds the error as errors.New(response.ErrorMessage). When the Twitch API response carries a non-empty ErrorMessage (e.g. from the GQL/streams query), Refresh passes it through handleError(widget, errors.New(response.ErrorMessage)) and stores it on the widget instead of populating stream data.

Source

Thrown at modules/twitch/widget.go:87

	case "followed":
		response, err = widget.twitch.FollowedStreams(&helix.FollowedStreamsParams{
			UserID: widget.twitch.UserID,
		})
	case "top":
		response, err = widget.twitch.TopStreams(&helix.StreamsParams{
			First:      widget.settings.numberOfResults,
			GameIDs:    widget.settings.gameIds,
			Language:   widget.settings.languages,
			Type:       widget.settings.streamType,
			UserIDs:    widget.settings.userIds,
			UserLogins: widget.settings.userLogins,
		})
	}

	if err != nil {
		handleError(widget, err)
	} else if response.ErrorMessage != "" {
		handleError(widget, errors.New(response.ErrorMessage))
	} else {
		streams := makeStreams(response)
		widget.topStreams = streams
		widget.err = nil
		if len(streams) <= widget.settings.numberOfResults {
			widget.SetItemCount(len(widget.topStreams))
		} else {
			widget.topStreams = streams[:widget.settings.numberOfResults]
			widget.SetItemCount(len(widget.topStreams))
		}
	}

	widget.Render()
}

func (widget *Widget) Render() {
	widget.Redraw(widget.content)
}

View on GitHub (pinned to bb838c1ccb)

Solutions

  1. Read the widget's displayed error text — it is Twitch's own message and indicates the precise cause.
  2. Regenerate the OAuth token / re-run the module's authentication step if the message mentions auth or token.
  3. Verify client-id and any username settings in the twitch module configuration.
  4. Retry later or update WTFUtil if the message indicates a GraphQL/schema error (API drift).

Example fix

// before: token expired, response.ErrorMessage = "Could not authenticate user"
// after: refresh credentials
// settings.yml
twitch:
  clientID: "<valid-client-id>"
  # re-run auth flow to refresh the token, then restart wtfutil
Defensive patterns

Strategy: try-catch

Validate before calling

if os.Getenv("TWITCH_CLIENT_ID") == "" || token == "" {
    return errors.New("Twitch clientID and OAuth token required before refresh")
}

Try / catch

if widget.err != nil {
    // widget surface shows Twitch's raw ErrorMessage; log and act:
    log.Printf("twitch API error: %v", widget.err)
    if strings.Contains(strings.ToLower(widget.err.Error()), "auth") {
        // refresh token / re-authenticate
    }
}

Prevention

When it happens

Trigger: Widget.Refresh() succeeds at the transport level but response.ErrorMessage != "" — i.e. the Twitch API returned an application-level error such as invalid client ID, invalid OAuth token, or a query error; the raw message text comes straight from Twitch.

Common situations: Expired or revoked Twitch OAuth token; wrong/missing client-id in module settings; Twitch API (GQL) changes or rate limiting; username lookup failing for an invalid channel name.

Related errors


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