Describe the bug
IAM Identity Center (IdC) login fails with 400 REQUEST_BODY_INVALID when the selected CodeWhisperer/Q Developer profile does not support the getUsageLimits API. A valid token is actually issued during the device-code flow, but the auth callback throws on the optional usage check and aborts the entire login.
To Reproduce
Steps to reproduce the behavior:
- Configure
~/.config/opencode/kiro.json for IdC with a profile ARN whose profile does not support the usage-limits API (e.g. a QDefaultProfile):
idc_start_url: https://<org>.awsapps.com/start
idc_region: eu-west-1
idc_profile_arn: arn:aws:codewhisperer:us-east-1:<acct>:profile/<id>
- Run
opencode auth login.
- Select provider
kiro → login method IAM Identity Center with Profile ARN.
- Complete the device-code sign-in at the verification URL.
- See error:
Failed to authorize: IDC authorization failed: Status: 400 (ValidationException) [<request-id>]: {"message":"Improperly formed request.","reason":"REQUEST_BODY_INVALID"}.
Expected behavior
Login should succeed. A failure of the optional getUsageLimits call (usage tracking is optional) should never block authentication — it should be skipped gracefully, the same way FEATURE_NOT_SUPPORTED already is. Setting usage_tracking_enabled: false should also skip the usage call during login.
Screenshots
Log from ~/.config/opencode/kiro-logs/plugin.log:
INFO: IDC authorize: resolved defaults {"oidcRegion":"eu-west-1","startUrl":"https://.awsapps.com"}
WARN: fetchUsageLimits failed during auth {"error":"Status: 400 (ValidationException) ...REQUEST_BODY_INVALID"}
ERROR: IDC auth callback failed Error: Status: 400 ...REQUEST_BODY_INVALID
at fetchUsageLimits (dist/plugin/usage.js:47:27)
at async dist/core/auth/idc-auth-method.js:95:39
Direct API test against q.us-east-1.amazonaws.com/getUsageLimits with a valid token + profile ARN (this profile supports none of the param combos):
| Attempt (params) |
HTTP |
Body |
AGENTIC_REQUEST + AI_EDITOR |
403 |
FEATURE_NOT_SUPPORTED |
AI_EDITOR only |
403 |
FEATURE_NOT_SUPPORTED |
CONVERSATION + AI_EDITOR |
400 |
REQUEST_BODY_INVALID |
no resourceType |
403 |
FEATURE_NOT_SUPPORTED |
Desktop (please complete the following information):
- OS: macOS (darwin, Apple Silicon / arm64)
- Browser: N/A (CLI / OpenCode)
- Version:
@zhafron/opencode-kiro-auth@2.0.0; auth method: IAM Identity Center with Profile ARN
Smartphone (please complete the following information):
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A
Additional context
Root cause is in the auth callback in dist/core/auth/idc-auth-method.js (~line 113), which only swallows FEATURE_NOT_SUPPORTED:
if (errMsg.includes('FEATURE_NOT_SUPPORTED')) {
// skip usage check
} else {
throw e; // REQUEST_BODY_INVALID lands here and aborts login
}
Suggested fix — treat REQUEST_BODY_INVALID the same as FEATURE_NOT_SUPPORTED:
if (errMsg.includes('FEATURE_NOT_SUPPORTED') || errMsg.includes('REQUEST_BODY_INVALID')) {
usage = { usedCount: 0, limitCount: 0, email: undefined };
} else {
throw e;
}
Also consider honoring usage_tracking_enabled: false during login — currently that flag is only checked at runtime (auth-handler / usage-tracker), not in the login path, so fetchUsageLimits is called unconditionally and setting the flag alone does not fix login.
Workaround: patching the condition above lets login complete (email falls back to a placeholder, token is stored and works).
Describe the bug
IAM Identity Center (IdC) login fails with
400 REQUEST_BODY_INVALIDwhen the selected CodeWhisperer/Q Developer profile does not support thegetUsageLimitsAPI. A valid token is actually issued during the device-code flow, but the auth callback throws on the optional usage check and aborts the entire login.To Reproduce
Steps to reproduce the behavior:
~/.config/opencode/kiro.jsonfor IdC with a profile ARN whose profile does not support the usage-limits API (e.g. aQDefaultProfile):idc_start_url:https://<org>.awsapps.com/startidc_region:eu-west-1idc_profile_arn:arn:aws:codewhisperer:us-east-1:<acct>:profile/<id>opencode auth login.kiro→ login methodIAM Identity Center with Profile ARN.Failed to authorize: IDC authorization failed: Status: 400 (ValidationException) [<request-id>]: {"message":"Improperly formed request.","reason":"REQUEST_BODY_INVALID"}.Expected behavior
Login should succeed. A failure of the optional
getUsageLimitscall (usage tracking is optional) should never block authentication — it should be skipped gracefully, the same wayFEATURE_NOT_SUPPORTEDalready is. Settingusage_tracking_enabled: falseshould also skip the usage call during login.Screenshots
Log from
~/.config/opencode/kiro-logs/plugin.log:INFO: IDC authorize: resolved defaults {"oidcRegion":"eu-west-1","startUrl":"https://.awsapps.com"}
WARN: fetchUsageLimits failed during auth {"error":"Status: 400 (ValidationException) ...REQUEST_BODY_INVALID"}
ERROR: IDC auth callback failed Error: Status: 400 ...REQUEST_BODY_INVALID
at fetchUsageLimits (dist/plugin/usage.js:47:27)
at async dist/core/auth/idc-auth-method.js:95:39
Direct API test against
q.us-east-1.amazonaws.com/getUsageLimitswith a valid token + profile ARN (this profile supports none of the param combos):AGENTIC_REQUEST+AI_EDITORFEATURE_NOT_SUPPORTEDAI_EDITORonlyFEATURE_NOT_SUPPORTEDCONVERSATION+AI_EDITORREQUEST_BODY_INVALIDresourceTypeFEATURE_NOT_SUPPORTEDDesktop (please complete the following information):
@zhafron/opencode-kiro-auth@2.0.0; auth method: IAM Identity Center with Profile ARNSmartphone (please complete the following information):
Additional context
Root cause is in the auth callback in
dist/core/auth/idc-auth-method.js(~line 113), which only swallowsFEATURE_NOT_SUPPORTED: