-
Notifications
You must be signed in to change notification settings - Fork 74
Open
Description
What is the problem?
The Twitch CLI panics after successfully outputting JSON from API calls. The panic occurs in the version checker and corrupts the output, making it impossible to parse programmatically with tools like jq.
Operating System
macOS 15.6 (Darwin 24.6.0), CLI Version: twitch-cli/1.1.24
Architecture Version (x86, x64, arm, etc)
ARM64
Steps to reproduce
- Run any API command that returns JSON:
twitch api get "extensions/transactions?extension_id=<extension-id>&first=2" - Observe that valid JSON is output first, followed by a panic:
goroutine 1 [running]:
github.com/twitchdev/twitch-cli/internal/util.areWeRunningLatestVersion()
/go/src/github.com/twitchdev/twitch-cli/internal/util/version_checker.go:121 +0x48c
Expected Behavior:
CLI should output clean JSON without panicking, or the version check should be separate from command execution.
Actual Behavior:
Every command (including twitch version) panics after execution, mixing panic output with valid JSON/output.
Impact:
- Cannot pipe CLI output to jq or other JSON parsers
- Scripts that rely on parsing CLI output fail
- Even twitch version command panics with exit code 2
Workaround:
Filter out panic lines before parsing:
twitch api get "..." 2>&1 | awk '/^panic:/ {exit} /^goroutine/ {exit} {print}' | jq
Relevant log output
{
"data": [
{
"broadcaster_id": "REDACTED",
"product_data": {
"cost": {
"amount": 300,
"type": "bits"
}
}
}
],
"pagination": {
"cursor": "..."
}
}
panic: runtime error: index out of range [0] with length 0
goroutine 1 [running]:
github.com/twitchdev/twitch-cli/internal/util.areWeRunningLatestVersion()
/go/src/github.com/twitchdev/twitch-cli/internal/util/version_checker.go:121 +0x48c
github.com/twitchdev/twitch-cli/internal/util.CheckForUpdatesAndPrintNotice()
/go/src/github.com/twitchdev/twitch-cli/internal/util/version_checker.go:46 +0x120Metadata
Metadata
Assignees
Labels
No labels