Skip to content

fix(auth): name the start URL, region and control planes when an IdC profile lookup fails - #35620

Merged
bolichen97 merged 1 commit into
mainfrom
fix/idc-no-profile-log
Nov 13, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/idc-no-profile-log

Conversation

@kyleseaman

@kyleseaman kyleseaman commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: When a company SSO (IAM Identity Center) sign-in ends with no Kiro profile, the gateway log says which start URL, region and Kiro control planes the lookup used, so the cause can be read from the log.

An Identity Center sign-in that finds no Kiro profile leaves one line in the log: IdC login has no available Kiro profiles. The line looks the same whether the browser approved the device code as a different Identity Center user, the start URL pointed at another organisation, or the region sent the lookup to the wrong control plane. A user who hit this six times in one morning had a log that could not tell those causes apart. A refused lookup (could not resolve IdC profile ARN) has the same gap.

Why it matters

Each of those causes has a different fix: sign in as the right user, use the right start URL, or pick the right region. With no start URL or region in the log, support has to ask the user to reproduce the failure and describe what they typed. The token is thrown away on these paths, so the log line is the only record of the attempt.

Not a goal

  • Changing which control planes are asked, or in what order. The lookup already asks every host, starting with the login region's own.
  • Changing what the dashboard shows. The no_kiro_profile and profile_lookup_failed codes stay as they are.
  • Logging which user approved the device code. The token does not say, and the lookup never sees it.

What changed (motivation → approach → change)

A refused profile lookup now ends with the start URL, the region and the control-plane hosts that were asked, in the order they were asked:

could not resolve IdC profile ARN (start URL https://acme.awsapps.com/start, region eu-west-1, control planes asked: https://management.eu-central-1.kiro.dev/, https://management.us-east-1.kiro.dev/): ListAvailableProfiles failed: HTTP 403 ...

The no-profile line (IdC login has no available Kiro profiles) already carries the same context on main, so it is left alone. That leaves the refused-lookup line as the one terminal failure that still said nothing about what was asked.

The host list comes from one new helper in auth/login/control_plane.py, control_plane_urls(region). list_available_profiles loops over that same list, so the log can't name hosts the lookup didn't call. auth/service.py builds the suffix from the pending login. All three values are configuration, and the access token is never put in the line.

Backwards compatibility

Compatible: only the text of one warning log line grows, and nothing parses it. The lookup's behaviour and return codes are unchanged.

Removes nothing: the diff adds context to one log line and pulls an existing expression out into a helper. No path, key, record or check is taken away.

Tests

test_poll_idc_refused_profile_lookup_logs_what_it_asked runs an eu-west-1 sign-in where every host refuses. It checks that the final warning names the start URL, the region and both hosts in lookup order (Frankfurt first), and that the access token is not in the line.

Proof: PROVEN test/test_kas_login_service.py::test_poll_idc_refused_profile_lookup_logs_what_it_asked (head 590e144)

test/test_kas_login_service.py and test/test_kas_auth_whoami.py pass (100 tests), along with isort, flake8, mypy, the repository semgrep rules and the flake-pattern ratchet.

Manual verification

N/A — unit coverage is enough: the change is the text of one log line, and the test drives the real poll path with fake control-plane answers.

Related Issues

None. No tracking issue was opened for this change.

Sibling sweep

Swept: git grep -n "list_available_profiles|no available Kiro profiles|could not resolve IdC" -- src/
Sibling: src/kiro_crew/auth/service.py:682 -- changed here
Sibling: src/kiro_crew/auth/login/control_plane.py:192 -- not affected -- the per-host refusal line already names its host

Pattern harvest

Not generalizable: the gap is specific to the lookup that throws away a redeemed token, where the log line is the only record of what was asked.

Checklist

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

@kyleseaman
kyleseaman requested review from a team and KiroCrewCaptain as code owners November 11, 2026 21:58
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 11, 2026
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 590e1440f89c40032915e653260741a47eea2be7 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 590e1440f89c40032915e653260741a47eea2be7 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 590e144

Verdict parsed from the review's SHA-scoped output markers for commit 590e1440f89c40032915e653260741a47eea2be7.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 590e1440f89c40032915e653260741a47eea2be7 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 590e1440f89c40032915e653260741a47eea2be7 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 590e144

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 590e1440f89c40032915e653260741a47eea2be7 false-positive: <reason, 20 to 500 characters>

@kyleseaman

Copy link
Copy Markdown
Contributor Author

Backend Tests reds on eddab8a are inherited from main, not this diff: main's own CI at 2df02ab (run 43105640841) fails the same shards. test_updates_handlers_facade is fixed by #35614 and test_wait_discipline_ratchet (test/test_update_boot_apply.py:335) by #35625, both from #35088. This PR waits for those to merge, then rebases. No override.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 5% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

This PR changes one log line. When an IdC profile lookup is refused, the warning now names the start URL, the region and the control-plane hosts that were asked. The host list comes from the new helper control_plane_urls, which list_available_profiles now loops over too, so the order is unchanged and the line only names hosts that were called. ControlPlaneError is only raised after every host has been asked, so "asked" is accurate. The start URL and region are configuration and already appear in the no-profile line on main. The token is not passed to the helper, and the new test asserts it is absent from the line. The test drives the real poll path and would fail without the change. Return codes and behaviour are unchanged.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit a4d7a00fb2 · 52 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 11, 2026
@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from eddab8a to 65a9720 Compare November 12, 2026 02:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 590e1440f89c40032915e653260741a47eea2be7 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. This adds diagnostic context to one log line, and the log names the hosts from the same helper the lookup loops over.

[DESIGN-REVIEWED] 590e144

Description read

[DESCRIPTION-READ] 0834b4d27102cfab736d984a405b6d7bdf045d57525da514624ec76dccd35976

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 590e1440f89c40032915e653260741a47eea2be7 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. One log line gets longer, the test fails on base, and the new helper has two real consumers.

Notes

  • Item 2 — oversized: "control planes asked: {hosts}" repeats hosts the log already names, one line per refusing host, from logger.warning("ListAvailableProfiles at %s failed: %s", url, err) (control_plane.py:192). The refused line was only missing the start URL and the region. Subtraction: drop control planes asked: from _idc_lookup_context, and control_plane_urls with it, so the suffix is just start URL and region.

What this change ships

Inventory (3 items) — 2 justified

Intent: when a company SSO profile lookup is refused, an operator can tell from the gateway log which start URL and region were used. FIX.

  1. The "could not resolve IdC profile ARN" warning now names the start URL and the region — justified
  2. The same warning also lists the control-plane hosts, in the order they were asked — oversized, the per-host refusal lines already name each host
  3. The host order now comes from a public helper, control_plane_urls(region), which the lookup itself also uses — justified

[FIRST-PRINCIPLES-REVIEWED] 590e144

Description read

[DESCRIPTION-READ] e9dfa93e65e80cebad4215fa54068d621a87ef9e1902d022f67edffbf609cd60

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased onto main 65a9720: #35625 fixed the inherited test_updates_handlers_facade and test_wait_discipline_ratchet reds. The PR's own patch is unchanged (git range-diff). CI is re-running.

@kyleseaman

Copy link
Copy Markdown
Contributor Author

Coverage Gate red on 65a9720 is inherited from main, not this diff: the per-file floor fails on src/kiro_crew/gateway_restart.py and src/kiro_crew/update_boot_apply.py, neither touched here. Tracked in #35713, fix in #35725. This PR waits for #35725, then rebases. No override.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from 65a9720 to dd8854d Compare November 12, 2026 04:45
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased onto main dd8854d: #35725 fixed the inherited Coverage Gate red (gateway_restart.py, update_boot_apply.py). The PR's own patch is unchanged (git range-diff). CI is re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Backend Tests (3.12, 2) red on dd8854d is inherited from main, not this diff: test/test_cloud_launch_customize.py::TestAmiArchitectureCheck::test_matching_architecture_proceeds_to_deploy fails since #35010 and fails locally on this tree, which touches no cloud code. Tracked in #35745, fix in #35746. This PR waits for #35746, then rebases. No override.

@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from dd8854d to cb2de4d Compare November 12, 2026 05:38
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased onto main cb2de4d: #35746 fixed the inherited TestAmiArchitectureCheck red (and the Coverage Gate that failed with it). The PR's own patch is unchanged (git range-diff). CI is re-running.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 12, 2026
bolichen97
bolichen97 previously approved these changes Nov 12, 2026

@bolichen97 bolichen97 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve at cb2de4d. Both failed IdC profile lookup log lines (profile_lookup_failed and no_kiro_profile) now name the start URL, the IdC region and the control planes asked, in the order sign-in asks them. That is enough to tell a wrong start URL or region from a browser approved as another user. control_plane_urls is the same dict.fromkeys list list_available_profiles already built, now shared. None of the logged values is a credential, and the test checks that the token stays out of the line. No regex added, no behaviour change beyond the log text, and nothing is live red.

Heads-up: #29398 rewrites the same no_kiro_profile warning in auth/service.py, so whichever of the two lands second will need a small rebase there.

@bolichen97
bolichen97 enabled auto-merge (squash) November 12, 2026 08:07
@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 12, 2026
@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from cb2de4d to ed6de61 Compare November 12, 2026 15:02
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased onto main ed6de61 to resolve the conflict with #29398, which already adds start URL, region, hosts and pages to the no-profile warning. This PR keeps main's no-profile line and now changes only the refused-lookup line ('could not resolve IdC profile ARN'), plus the shared control_plane_urls helper. Its test is narrowed to that path. CI is re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 12, 2026
@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from ed6de61 to 56ec85a Compare November 12, 2026 16:00
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/cli_kas_login.py and test/test_cli_kas_login.py (import overlap) since this head went green (cec6f7a -> e7e2146); CI re-running.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from 56ec85a to a4d7a00 Compare November 12, 2026 18:41
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in test/test_api_models_kas_bundle.py (import overlap) since this head went green (e7e2146 -> f3b8c89); CI re-running.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 12, 2026
@kyleseaman
kyleseaman force-pushed the fix/idc-no-profile-log branch from a4d7a00 to 590e144 Compare November 12, 2026 19:50
@kyleseaman

Copy link
Copy Markdown
Contributor Author

Rebased: main moved in src/kiro_crew/auth/service.py, src/kiro_crew/auth/login/builder_id.py and test/test_kas_login_oidc_reuse.py since this head went green (f3b8c89 -> 0fc3b49); CI re-running.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention labels Nov 12, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving. On head 590e144 the review checked these points. The control_plane_urls() extraction asks the same hosts in the same order as before. The refused-lookup warning names only the start URL, the region and the fixed control plane hosts, never the access token. Both return codes and the no-profile line are unchanged. The new test passed in 5 out of 5 repeat runs and the whole test file passed (81 tests). The new test goes red when either production change is reverted.

Done well: the lookup loop and the log suffix both read from one control_plane_urls(region), so on this head the log names exactly the hosts the lookup asked. The test also drives eu-west-1 to check the region-first host order.

Optional:

  • Whichever of #36242 or #36188 lands after this PR should send its override or viewer host through control_plane_urls(). Otherwise this warning would name hosts the lookup never asked.
  • In test_poll_idc_refused_profile_lookup_logs_what_it_asked, keep the session and assert [u for u, _ in session.calls[1:]] == [_EU_CPS, _US_CPS]. That ties the logged list to the requests that were actually sent.
  • The First-principles note on the host list has no reply yet. One rebuttal is the case where one host refuses and another answers empty. The empty host is logged nowhere else.

@bolichen97
bolichen97 merged commit a5815c1 into main Nov 13, 2026
101 of 108 checks passed
@bolichen97
bolichen97 deleted the fix/idc-no-profile-log branch November 13, 2026 02:04
kyleseaman pushed a commit to Skripd/KiroCrew that referenced this pull request Nov 13, 2026
Resolves the conflict with main's control_plane_urls (kirodotdev#35620), which does what this branch's _discovery_hosts did: the host walk and its test now use main's public helper.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

readiness: passed Eligible automated validation passed for the current revision

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants