Commit 43fc638
fix(auth): resolve MFA option by label, type, or display string (#128)
## Summary
- `--mfa-option-id` now accepts the MFA option **label** (e.g. `"Get a
text"`), **type** (e.g. `"sms"`), or the **display string** (e.g. `"Get
a text (sms)"`) — all resolve to the correct type before hitting the API
- Unknown MFA options now produce a clear error listing available
choices instead of silently looping
## Problem
When PayPal presented MFA options like `"Get a text (sms)"`, users
naturally passed `--mfa-option-id "Get a text"` (the label). The CLI
sent this directly to the API, which expects the type (`"sms"`). The
backend didn't recognize the label, causing the flow to silently loop
back to the MFA selection screen with no error.
## Fix
Before submitting, the CLI now fetches the connection's available MFA
options and resolves the user's input (case-insensitive) against label,
type, or combined display string. The resolved type is always sent to
the API.
## Test plan
- [x] `TestSubmit_MfaOptionResolvesType` — passing type directly still
works
- [x] `TestSubmit_MfaOptionResolvesLabel` — passing label resolves to
type
- [x] `TestSubmit_MfaOptionResolvesDisplayString` — passing `"Label
(type)"` resolves to type
- [x] `TestSubmit_MfaOptionResolvesLabelCaseInsensitive` —
case-insensitive matching
- [x] `TestSubmit_MfaOptionRejectsUnknown` — unknown option returns
error with available options
- [x] Full `go test ./cmd/` passes
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> **Medium Risk**
> Changes the `auth connections submit` MFA selection path by adding an
extra `Get` call and transforming user input before sending it to the
API, which could affect login flows if option resolution mismatches or
the prefetch fails.
>
> **Overview**
> `auth connections submit` now resolves `--mfa-option-id`
case-insensitively against the connection’s available MFA options,
accepting a **type**, **label**, or **"Label (type)"** display string
and always submitting the resolved option *type* to the API.
>
> If the provided MFA option doesn’t match any available option,
submission now fails fast with a clear error listing the valid choices,
and new unit tests cover the supported inputs plus fetch/error handling.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
3c45ed6. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>1 parent f06b05a commit 43fc638
2 files changed
Lines changed: 166 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
450 | 450 | | |
451 | 451 | | |
452 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
| 477 | + | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
453 | 484 | | |
454 | 485 | | |
455 | 486 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
0 commit comments