fix: validate API key against Resend API before saving#85
Merged
felipefreitag merged 5 commits intoresend:mainfrom Mar 16, 2026
Merged
fix: validate API key against Resend API before saving#85felipefreitag merged 5 commits intoresend:mainfrom
felipefreitag merged 5 commits intoresend:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/commands/auth/login.test.ts">
<violation number="1" location="tests/commands/auth/login.test.ts:81">
P2: Invalid-key regression test does not verify that credentials are not persisted, leaving the PR’s core guarantee unprotected.</violation>
</file>
Since this is your first cubic review, here's how it works:
- cubic automatically reviews your code and comments on bugs and improvements
- Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
- Add one-off context when rerunning by tagging
@cubic-dev-aiwith guidance or docs links (includingllms.txt) - Ask questions if you need clarification on any suggestion
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
The login command accepted any key with the re_ prefix without verifying it against the API. The Resend SDK returns errors in the response object rather than throwing exceptions, so the try/catch block never caught invalid keys. Check the error field in the response from resend.domains.list() and exit with validation_failed if the API rejects the key. Fixes resend#70
e58687c to
0a6944d
Compare
Contributor
|
I was able to test this, and it looks good to me Before: After |
Without the early return, execution continues to spinner.stop('API key is valid')
even when the API rejects the key.
Contributor
There was a problem hiding this comment.
1 issue found across 1 file (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/commands/auth/login.ts">
<violation number="1" location="src/commands/auth/login.ts:150">
P2: Validation uses `domains.list()` and now hard-fails on any error, which rejects valid `sending_access` API keys that lack domain-read permissions.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
felipefreitag
approved these changes
Mar 16, 2026
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.
The login command accepted any key with the re_ prefix without verifying it against the API. The Resend SDK returns errors in the response object rather than throwing exceptions, so the try/catch block never caught invalid keys.
Check the error field in the response from resend.domains.list() and exit with validation_failed if the API rejects the key.
Fixes #70
Summary by cubic
Validate the API key during
loginby calling the Resend API and reject invalid keys before saving. This prevents saving bad keys and shows a clear validation error from the API.{ error }fromresend.domains.list(); on error, fail the spinner,outputErrorwith codevalidation_failed, and return to avoid the "valid" message and skip writing credentials.resendresponses and add an invalid-key case; assert exit code 1, thevalidation_failederror, and no credentials file.Written for commit f4a361b. Summary will update on new commits.