glanceapp/glance · error
unknown operation name: %s
Error message
unknown operation name: %s
What it means
The switch over response[i].Extensions.OperationName hit its default case: the GQL response contained an operation name other than the two expected ('ChannelShell', 'StreamMetadata'). Twitch either added an operation to the persisted batch, renamed one, or returned an error envelope whose operation name is unrecognized.
Source
Thrown at internal/glance/widget-twitch-channels.go:165
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)
}
}
if channelShell.UserOrError.Type != "User" {
result.Name = result.Login
return result, nil
}
result.Exists = true
result.Name = channelShell.UserOrError.DisplayName
result.AvatarUrl = channelShell.UserOrError.ProfileImageUrl
if channelShell.UserOrError.Stream != nil {
result.IsLive = true
result.ViewersCount = channelShell.UserOrError.Stream.ViewersCount
if streamMetadata.UserOrNull != nil && streamMetadata.UserOrNull.Stream != nil {
if streamMetadata.UserOrNull.LastBroadcast != nil {View on GitHub (pinned to 91324e8de7)
Solutions
- Log the full Extensions of the unexpected operation to see what Twitch returned
- Update the persisted query payload and the switch cases in internal/glance/widget-twitch-channels.go to handle the new operation name (or ignore unknown ones instead of failing)
- Upgrade Glance to a release matching the current Twitch GQL contract
Example fix
// before
default:
return result, fmt.Errorf("unknown operation name: %s", response[i].Extensions.OperationName)
// after (skip operations we don't consume)
default:
slog.Warn("Unknown twitch GQL operation", "op", response[i].Extensions.OperationName)
continue Defensive patterns
Strategy: fallback
Type guard
func isKnownOperation(name string) bool {
return name == "ChannelShell" || name == "StreamMetadata"
} Try / catch
result, err := fetchChannel(login)
if err != nil && strings.HasPrefix(err.Error(), "unknown operation name") {
// skip unknown operations instead of failing the whole widget (requires code change)
slog.Warn("ignoring unknown twitch operation", "err", err)
} Prevention
- Treat unknown operation names as skippable, not fatal, when patching the widget
- Validate operation names against a whitelist before unmarshalling
When it happens
Trigger: Twitch adds a third operation to the batched persisted query, renames an operation, or the persisted query hash resolves to a different set of operations than the code was built for.
Common situations: Version skew: an old persisted-query hash still accepted but returning different operations; Twitch experimenting with the channel page query set; all Twitch channel lookups fail at once.
Related errors
- unmarshalling channel shell: %w
- unmarshalling stream metadata: %w
- no categories could be retrieved
- expected 2 operation responses, got %d
- %w: failed to fetch %d channels
AI-assisted analysis of glanceapp/glance@91324e8de7 (2026-08-15).
Data as JSON: /api/errors/570764411e4b0cd1.
Report an issue: GitHub.