fix(cmd): prevent panic in test command with empty API keys#20
Merged
Conversation
The test command would panic when trying to slice empty API keys for masking. This occurred when users authenticate via OAuth2 instead of API keys, since config validation only requires Site to be set. Changes: - Add length checks before slicing API/App keys in test command (root.go:210-227) - Display helpful messages for empty keys (OAuth2 auth) - Show warnings for keys that are too short to be valid - Add comprehensive tests for all edge cases (root_test.go:235-320) Fixes panic: runtime error: slice bounds out of range [:8] with length 0 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The CI was failing when the Comment on PR step couldn't authenticate, even though the actual tests passed successfully. This is a common issue with GitHub Actions permissions on PRs. Making this step non-blocking ensures CI passes when tests succeed, regardless of comment posting permissions. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
📊 Test Coverage ReportThreshold: 80% ✅ Coverage by Package📈 Coverage Status: ✅ PASSED - Coverage meets minimum threshold Updated for commit 54c9eee |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixed a panic in the
pup testcommand that occurred when API keys were not set (e.g., when using OAuth2 authentication).Problem
The test command attempted to slice API keys for masking without checking if they existed or had sufficient length, causing a panic:
This occurred because config validation only requires
Siteto be set, allowing empty API keys when OAuth2 authentication is used.Changes
TestTestCmd_EmptyKeys- Empty API keys don't panicTestTestCmd_ShortKeys- Short keys display warningTestTestCmd_ValidKeys- Valid keys are properly maskedTestTestCmd_InvalidSite- Validation still enforces required SiteTesting
🤖 Generated with Claude Code