Repository navigation
fix(kiro): route API-key connections to the Amazon Q region and auto-detect it at import - #16497
Merged
diegosouzapw merged 4 commits intoOct 17, 2026
Conversation
…detect it at import Long-lived Kiro API keys authenticate only on the regional Amazon Q host (q.<region>.amazonaws.com). In us-east-1 OmniRoute sent them to codewhisperer.us-east-1, which rejects API-key payloads with HTTP 400, and the import validated keys through ListAvailableProfiles, which AWS denies for every API key — so a dead or mistyped key imported "successfully". - executor: api_key connections always target q.<region>/generateAssistantResponse (us-east-1 included); region restricted to us-east-1 / eu-central-1, falling back to us-east-1. IdC, external IdP and social routing are unchanged. - import: validateApiKey probes q.<region>/ListAvailableModels (10 s timeout per region). "auto" (new default) tries us-east-1 then eu-central-1 and pins the first region that accepts the key; rejection everywhere fails the import with HTTP 400, upstream outages surface as 500. Profile discovery stays best-effort. - schema: region is an allowlist (auto | us-east-1 | eu-central-1) instead of free text. - provider test: validates in the exact region the executor routes to; the runtime probe uses the q.* host. - dashboard: region select (Auto / US East / Frankfurt) with labels in all locales. Co-authored-by: ryanngit <ryanngit@users.noreply.github.com> Inspired-by: decolua/9router#3185
Contributor
CI Coverage Report
Coverage artifact was not available for this run. |
Relocate the four Kiro API-key validator tests (updated for the Amazon Q region catalog probe) out of the frozen provider-validation-specialty.test.ts into tests/unit/kiro-validation-region-16497.test.ts. Every assertion is kept.
diegosouzapw
deleted the
fix/port-pr-3185-kiro-api-key-amazon-q-region
branch
October 18, 2026 23:50
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.
Summary
q.<region>.amazonaws.com), us-east-1 included. Before this change, us-east-1 keys went tocodewhisperer.us-east-1, which rejects API-key payloads with HTTP 400.q.<region>/ListAvailableModels. Before, it only calledListAvailableProfiles, and AWS denies that call for every API key, so a dead or mistyped key imported "successfully". The new default region isauto: it tries us-east-1, then eu-central-1, and saves the first region that accepts the key.Attribution
Thanks to @ryanngit for the original implementation.
Changes
open-sse/services/kiroRegion.ts: addskiroApiKeyRuntimeHost()/resolveKiroApiKeyRegion(). The region must be us-east-1 or eu-central-1 (anything else falls back to us-east-1) because it goes into a hostname.open-sse/executors/kiro.ts:api_keyconnections always use the single q.* URL. IdC, external IdP and social routing are unchanged (regression tests included).src/lib/oauth/services/kiro.ts:validateApiKey(apiKey, "auto" | region)checks the key withListAvailableModels(tokentype: API_KEY, 10 s timeout per region).Invalid Kiro API key …(HTTP 400).Kiro API key validation failed …(HTTP 500).ListAvailableProfilesstill runs afterwards, best-effort, to discover aprofileArn(now with a timeout).src/shared/validation/schemas/auth.ts:kiroApiKeyImportSchema.regiononly acceptsauto | us-east-1 | eu-central-1(defaultauto). It used to accept free text.src/app/api/oauth/kiro/api-key/route.ts: defaults toauto.src/lib/providers/validation/{specialtyInline,kiro}.ts: the provider test validates in the same region the executor routes to, and the runtime probe uses the q.* host.src/shared/components/KiroAuthModal.tsx+ 67 locale catalogs: replaces the oldapiKeyRegionDescriptionkey (it said "default: us-east-1", which is no longer true) with 4 new keys, translated in every locale (no__MISSING__markers).docs/guides/KIRO_SETUP.md: documents the new import and routing contract.kiro-api-key-service,provider-validation-specialty(kiro cases): stubs now answer theListAvailableModelsproof first; call counts grow by one.validation-kiro-split: the probe now targets q.us-east-1.kiro-content-stall-15260,kiro-builderid-branded-gateway-profilearn-400: api_key us-east-1 now expects the q.us-east-1 URL.Test plan
New tests, each run against the old code first and then after the change:
tests/unit/kiro-api-key-amazon-q-routing.test.tscodewhisperer.us-east-1, a bogus region did not fall back, 403 handling). ThekiroApiKeyRuntimeHosttests did not load because the export did not exist yet.ℹ tests 8 ℹ pass 8 ℹ fail 0.tests/unit/kiro-api-key-validate-region.test.tsℹ tests 7 ℹ pass 1 ℹ fail 6.ℹ pass 7 ℹ fail 0.tests/unit/shared/components/KiroAuthModal.test.tsx(vitest UI config)Tests 1 failed | 4 passed (5).Tests 5 passed (5).Related suites (
characterization-oauth,executor-kiro, everykiro-*.test.ts,kiroThinking,oauth-routes-manage-scope,provider-health-inconclusive-probes,validation-kiro-split,validation-specialty-inline-split,provider-validation-specialty):ℹ tests 463 ℹ pass 461 ℹ fail 2. Both failures are not caused by this PR:gemini-web validator: 200 from gemini.google.com → validalso fails with the release/v3.8.52 source files swapped back in (ℹ pass 0 ℹ fail 1).#15260timing test failed once under load; run alone it passed 3/3 (ℹ pass 12 ℹ fail 0).Static checks:
npx eslint --suppressions-location config/quality/eslint-suppressions.json <changed files>→ rc=0npx prettier --check <changed files>→ all formattednpm run typecheck:core→ cleancheck:public-credsOK ·check:route-validation:t06PASS ·check:any-budget:t11PASS ·check:docs-allrc=0i18n:check-keys: OK, 66 locales carry all 13747 keysi18n:check-ratio: OKi18n:check-new-keys: PASSi18n:check-ui-coverage: PASScheck:ui-icu: PASSℹ tests 16 ℹ pass 16check-pr-test-policy(PR mode): PASS ·check:test-masking: OK, no weakeninglive_check (hold-vps)
This changes how a real provider is routed and has not been tested against a real key yet (Hard Rule #18). Run these on the VPS before merging:
autothrough the dashboard. Expected: HTTP 200, and the savedproviderSpecificData.regionmatches the key's home region.q.us-east-1.amazonaws.com/generateAssistantResponse, and theX-Amz-Targetheader the executor still sends is accepted on q.*.Invalid Kiro API key ….codewhisperer.us-east-1fails on q.us-east-1, add codewhisperer back as a second candidate before merging.