-
Notifications
You must be signed in to change notification settings - Fork 36
Fix: Add missing error handling for Keypair.fromSecret() in API #88
Copy link
Copy link
Open
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave programapiREST API componentREST API componentbugSomething isn't workingSomething isn't workingeasyDifficulty: EasyDifficulty: Easy
Description
Problem
In api/src/services/stellar.service.ts, Keypair.fromSecret(userSecret) is called inside try-catch blocks, but the error message doesn't distinguish between invalid key format vs other errors.
Context
If a user provides an invalid secret key, the error message is generic. Users need to know specifically that their key format is wrong.
Proposed Solution
Catch the specific error from Keypair.fromSecret():
try {
const keypair = Keypair.fromSecret(userSecret);
} catch (error) {
if (error instanceof Error && error.message.includes('Invalid')) {
throw new ApiError(400, 'Invalid secret key format');
}
throw error;
}Acceptance Criteria
- Invalid secret key returns 400 with specific message
- Valid but wrong key proceeds normally
- Error message does NOT echo the key value
- Tests for invalid key scenarios
Technical Notes
- File:
api/src/services/stellar.service.ts
Constraints
- Never include the key value in error responses or logs
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave programapiREST API componentREST API componentbugSomething isn't workingSomething isn't workingeasyDifficulty: EasyDifficulty: Easy