Skip to content

TPT-4175: cli: Update interactive config token access check#881

Open
mgwoj wants to merge 2 commits intolinode:devfrom
mgwoj:feature/TPT-4175-cli-update-interactive-config-token-access-check
Open

TPT-4175: cli: Update interactive config token access check#881
mgwoj wants to merge 2 commits intolinode:devfrom
mgwoj:feature/TPT-4175-cli-update-interactive-config-token-access-check

Conversation

@mgwoj
Copy link
Copy Markdown
Contributor

@mgwoj mgwoj commented Apr 28, 2026

📝 Description

AM Users wont have access to /profile/grants so we need to come up with a new way to check the access level of an account so it can add auth users.

✔️ How to Test

make test-unit

@mgwoj mgwoj requested a review from Copilot April 28, 2026 11:10
@mgwoj mgwoj requested review from a team as code owners April 28, 2026 11:10
@mgwoj mgwoj added the improvement for improvements in existing functionality in the changelog. label Apr 28, 2026
@mgwoj mgwoj requested review from ckulinsk and yec-akamai and removed request for a team April 28, 2026 11:10
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the CLI’s token “full access” check used during interactive configuration to avoid failing hard when /profile/grants is inaccessible (notably for IAM-enrolled users).

Changes:

  • Update _check_full_access to treat HTTP 403 from /profile/grants as a non-fatal response and interpret it as “not full access”.
  • Add unit tests covering _check_full_access behavior for 204/200/403 responses.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
linodecli/configuration/auth.py Adjusts response handling for /profile/grants to allow 403 without exiting.
tests/unit/test_configuration.py Adds unit tests verifying _check_full_access return values for key status codes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +179 to +186
# IAM-enrolled users receive a 403 from /profile/grants since that
# endpoint is not accessible to them. Treat 403 as a valid response
# (i.e. not full access) rather than a fatal error.
_handle_response_status(
result,
exit_on_error=True,
status_validator=lambda status: status == 403,
)
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

Treating a 403 from /profile/grants as a non-fatal response makes _check_full_access return False for IAM-enrolled users. In CLIConfig.configure() this value gates the /account/users lookup, so IAM users will never be offered authorized_users selection even if they otherwise have the needed account permissions. If the intent is to still support configuring authorized users for IAM tokens, consider falling back to a different capability check (e.g. attempt /account/users with a status_validator for 401/403) or decouple the authorized-users prompt from _check_full_access when the grants endpoint is inaccessible.

Copilot uses AI. Check for mistakes.
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.

@jriddle-linode Thoughts on this? I can't seem to reproduce the issue that requires this change but I might not be properly enrolled in IAM

Comment thread tests/unit/test_configuration.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement for improvements in existing functionality in the changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants