glanceapp/glance · error
expected 2 operation responses, got %d
Error message
expected 2 operation responses, got %d
What it means
Returned by the Twitch channels widget (internal/glance/widget-twitch-channels.go:148) when the batched GraphQL request to Twitch's GQL endpoint (two operations in one POST body: ChannelShell + StreamMetadata, both for the same channel name) decoded successfully as JSON but did not yield exactly 2 operation responses. Twitch acknowledged the request but returned a different number of operations — typically 0 (error envelope) or 1 (one operation dropped/failed server-side).
Source
Thrown at internal/glance/widget-twitch-channels.go:148
// what the limit is for max operations per request and batch operations in
// multiple requests if number of channels exceeds allowed limit.
func fetchChannelFromTwitchTask(channel string) (twitchChannel, error) {
result := twitchChannel{
Login: strings.ToLower(channel),
}
reader := strings.NewReader(fmt.Sprintf(twitchChannelStatusOperationRequestBody, channel, channel))
request, _ := http.NewRequest("POST", twitchGqlEndpoint, reader)
request.Header.Add("Client-ID", twitchGqlClientId)
response, err := decodeJsonFromRequest[[]twitchOperationResponse](defaultHTTPClient, request)
if err != nil {
return result, err
}
if len(response) != 2 {
return result, fmt.Errorf("expected 2 operation responses, got %d", len(response))
}
var channelShell twitchChannelShellOperationResponse
var streamMetadata twitchStreamMetadataOperationResponse
for i := range response {
switch response[i].Extensions.OperationName {
case "ChannelShell":
if err = json.Unmarshal(response[i].Data, &channelShell); err != nil {
return result, fmt.Errorf("unmarshalling channel shell: %w", err)
}
case "StreamMetadata":
if err = json.Unmarshal(response[i].Data, &streamMetadata); err != nil {
return result, fmt.Errorf("unmarshalling stream metadata: %w", err)
}
default:
return result, fmt.Errorf("unknown operation name: %s", response[i].Extensions.OperationName)
}View on GitHub (pinned to 91324e8de7)
Solutions
- Update Glance — Twitch GQL breakage is fixed upstream when Twitch changes shapes
- Verify the channel exists and its exact current name at twitch.tv
- Remove or correct the failing channel entry; sibling channels in the widget continue independently
- Report upstream with the channel name and Glance version if the channel is valid
Defensive patterns
Strategy: retry
Validate before calling
// Verify channel exists before adding it (public API)
resp, _ := http.Get("https://www.twitch.tv/" + channel)
// non-200 => GQL batch will likely fail Try / catch
if err != nil && strings.Contains(err.Error(), "expected 2 operation responses") {
// Twitch GQL shape drift or bad channel; retry later, update Glance
} Prevention
- Track channels by their exact current names
- Update Glance when Twitch changes its GQL schema
- Isolate suspicious channels to identify the offender
When it happens
Trigger: POST to twitchGqlEndpoint with the two-operation body returning [] or a single-element array: Twitch GQL errors on the batch (invalid channel name, renamed/deleted channel), a GQL syntax/schema change collapsing the batch, or an error response shape that decodes as a short array instead of the expected pair.
Common situations: Channel renamed or suspended so ChannelShell/StreamMetadata ops fail; Twitch changing their undocumented GQL schema after a Glance release (these errors arrive in waves, like the Reddit ones); special characters in the channel field.
Related errors
- no categories could be retrieved
- unmarshalling channel shell: %w
- unmarshalling stream metadata: %w
- unknown operation name: %s
- %w: failed to fetch %d channels
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/f79206295cc6e125.
Report an issue: GitHub.