fix(review): address coderabbit code review feedback
- commit
- 0a85e4eb01d3fbe4271b7cdc24bc220a246ab983
- author
- bnema · · 2026-01-31 21:22 UTC
- parent
- d2f6768
- signature
- GPG Verified
CD88F9E564E0102646FB6077A1A07C7C7C3E349D· arch-gpg Verified for the committer email
2 files · +9 -4
M internal/adapters/in/cli/auth.go +6 -3
| @@ -271,7 +271,6 @@ func runAuthLogin(remoteName, username, password string) error { | |||
| 271 | 271 | return fmt.Errorf("username cannot be empty") | |
| 272 | 272 | } | |
| 273 | 273 | ||
| 274 | - | password = strings.TrimSpace(password) | |
| 275 | 274 | if password == "" { | |
| 276 | 275 | // Prompt for password (hidden input) | |
| 277 | 276 | fmt.Print("Password: ") | |
| @@ -283,10 +282,14 @@ func runAuthLogin(remoteName, username, password string) error { | |||
| 283 | 282 | if readErr != nil { | |
| 284 | 283 | return fmt.Errorf("failed to read password: %w", readErr) | |
| 285 | 284 | } | |
| 286 | - | passwordBytes = []byte(strings.TrimSpace(passwordInput)) | |
| 285 | + | // Only trim trailing newline from fallback input | |
| 286 | + | passwordBytes = []byte(strings.TrimRight(passwordInput, "\r\n")) | |
| 287 | 287 | } | |
| 288 | 288 | fmt.Println() | |
| 289 | - | password = strings.TrimSpace(string(passwordBytes)) | |
| 289 | + | password = string(passwordBytes) | |
| 290 | + | } else { | |
| 291 | + | // Only trim trailing newline from flag-provided password | |
| 292 | + | password = strings.TrimRight(password, "\r\n") | |
| 290 | 293 | } | |
| 291 | 294 | ||
| 292 | 295 | if password == "" { | |
| @@ -271,7 +271,6 @@ func runAuthLogin(remoteName, username, password string) error { | |||||
| 271 | return fmt.Errorf("username cannot be empty") | 271 | return fmt.Errorf("username cannot be empty") | ||
| 272 | } | 272 | } | ||
| 273 | 273 | ||||
| 274 | - | password = strings.TrimSpace(password) | |||
| 275 | if password == "" { | 274 | if password == "" { | ||
| 276 | // Prompt for password (hidden input) | 275 | // Prompt for password (hidden input) | ||
| 277 | fmt.Print("Password: ") | 276 | fmt.Print("Password: ") | ||
| @@ -283,10 +282,14 @@ func runAuthLogin(remoteName, username, password string) error { | |||||
| 283 | if readErr != nil { | 282 | if readErr != nil { | ||
| 284 | return fmt.Errorf("failed to read password: %w", readErr) | 283 | return fmt.Errorf("failed to read password: %w", readErr) | ||
| 285 | } | 284 | } | ||
| 286 | - | passwordBytes = []byte(strings.TrimSpace(passwordInput)) | 285 | + | // Only trim trailing newline from fallback input |
| 286 | + | passwordBytes = []byte(strings.TrimRight(passwordInput, "\r\n")) | |||
| 287 | } | 287 | } | ||
| 288 | fmt.Println() | 288 | fmt.Println() | ||
| 289 | - | password = strings.TrimSpace(string(passwordBytes)) | 289 | + | password = string(passwordBytes) |
| 290 | + | } else { | |||
| 291 | + | // Only trim trailing newline from flag-provided password | |||
| 292 | + | password = strings.TrimRight(password, "\r\n") | |||
| 290 | } | 293 | } | ||
| 291 | 294 | ||||
| 292 | if password == "" { | 295 | if password == "" { | ||
M internal/adapters/out/domainsecrets/pass_store.go +3 -1
| @@ -257,7 +257,9 @@ func (s *PassStore) ListAttachmentKeys(domainName string) ([]out.AttachmentSecre | |||
| 257 | 257 | return nil, err | |
| 258 | 258 | } | |
| 259 | 259 | ||
| 260 | - | content, exists, err := s.passShow(ctx, manifestPath) | |
| 260 | + | showCtx, showCancel := context.WithTimeout(context.Background(), s.timeout) | |
| 261 | + | content, exists, err := s.passShow(showCtx, manifestPath) | |
| 262 | + | showCancel() | |
| 261 | 263 | if err != nil { | |
| 262 | 264 | return nil, err | |
| 263 | 265 | } | |
| @@ -257,7 +257,9 @@ func (s *PassStore) ListAttachmentKeys(domainName string) ([]out.AttachmentSecre | |||||
| 257 | return nil, err | 257 | return nil, err | ||
| 258 | } | 258 | } | ||
| 259 | 259 | ||||
| 260 | - | content, exists, err := s.passShow(ctx, manifestPath) | 260 | + | showCtx, showCancel := context.WithTimeout(context.Background(), s.timeout) |
| 261 | + | content, exists, err := s.passShow(showCtx, manifestPath) | |||
| 262 | + | showCancel() | |||
| 261 | if err != nil { | 263 | if err != nil { | ||
| 262 | return nil, err | 264 | return nil, err | ||
| 263 | } | 265 | } | ||