Skip to content

fix(auth): complete public error boundary in _create_cognito - #142

Merged
NodeJSmith merged 4 commits into
mainfrom
141
Aug 11, 2026
Merged

fix(auth): complete public error boundary in _create_cognito#142
NodeJSmith merged 4 commits into
mainfrom
141

Conversation

@NodeJSmith

@NodeJSmith NodeJSmith commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Notable Changes

  • _create_cognito now handles BotoCoreError (connectivity, timeout, endpoint resolution) separately from ClientError, wrapping it in OtfTransportError instead of letting it fall through to the generic except Exception re-raise. ClientError is a sibling of BotoCoreError, not a subclass, so the new branch only ever catches non-API construction-time failures.
  • OtfAuthenticationError raised from ClientError now carries a fixed, safe message ("OTF authentication failed") instead of the raw Cognito exception text, which could leak provider-specific detail. The original exception is still preserved via __cause__ for debugging.
  • Added tests covering both the safe-message behavior and the new transport-error path for construction-time connectivity failures.

Closes #141

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of authentication failures with a clear, safe error message.
    • Separated service connectivity failures from authentication errors for more accurate reporting.
    • Prevented provider-specific error details from being exposed.
  • Tests
    • Added coverage for authentication failures and connectivity errors.

Wrap construction-time BotoCoreError failures (connectivity, timeout,
endpoint resolution) in OtfTransportError, and use a fixed safe
message for OtfAuthenticationError instead of raw Cognito exception
text. Both preserve the original exception via __cause__.

Closes #141
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@NodeJSmith, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 17 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e3fd0ef1-cd66-4920-beb3-4d9a03e64bd6

📥 Commits

Reviewing files that changed from the base of the PR and between 8aa3f36 and 28f6ce2.

📒 Files selected for processing (6)
  • docs/guides/error-handling.md
  • src/otf_api/auth/auth.py
  • src/otf_api/auth/user.py
  • src/otf_api/exceptions.py
  • tests/test_api/test_errors.py
  • tests/test_auth/test_otf_cognito.py
📝 Walkthrough

Walkthrough

OtfUser now separates Cognito authentication failures from transport failures. Authentication errors use fixed safe text. Transport failures become OtfTransportError with chained causes. Tests cover message redaction and constructor-time connectivity failures.

Changes

OtfUser error handling

Layer / File(s) Summary
Translate Cognito failures
src/otf_api/auth/user.py
ClientError now raises OtfAuthenticationError with a fixed message. Non-API BotoCoreError failures now raise OtfTransportError with the original cause chained.
Validate public error behavior
tests/test_api/test_errors.py
Tests verify safe authentication messages and constructor-time EndpointConnectionError wrapping with preserved causes.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main change: completing the authentication error boundary in _create_cognito.
Linked Issues check ✅ Passed The changes meet issue #141 by safely translating authentication and transport failures, preserving causes, and adding regression tests.
Out of Scope Changes check ✅ Passed All changes are limited to _create_cognito error handling and related regression tests, with no unrelated or downstream changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@NodeJSmith
NodeJSmith marked this pull request as ready for review August 11, 2026 20:34
Copilot AI lite review requested due to automatic review settings August 11, 2026 20:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8aa3f36084

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/otf_api/auth/user.py
Mirror the _create_cognito fix at OtfCognito.check_token(): wrap
refresh-time BotoCoreError failures in OtfTransportError, use a fixed
safe message for the OtfAuthenticationError fallback instead of raw
Cognito text, and log before raising (matching the sibling path).

Follow-up to #141
Copilot AI review requested due to automatic review settings August 11, 2026 20:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f6faffb8d1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/otf_api/auth/auth.py Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 68c0862d-4e22-4f74-a92d-10681f9311f9

📥 Commits

Reviewing files that changed from the base of the PR and between a2ff24c and 8aa3f36.

📒 Files selected for processing (2)
  • src/otf_api/auth/user.py
  • tests/test_api/test_errors.py

Comment thread src/otf_api/auth/user.py Outdated
Narrow the BotoCoreError catch in _create_cognito and check_token to only
report OtfTransportError for genuine transport failures (ConnectionError,
HTTPClientError subclasses). Other BotoCoreError subtypes (ParamValidationError,
ProfileNotFound, NoRegionError, etc.) are configuration/validation failures
that retrying cannot fix, so they now raise the new OtfConfigurationError
instead of being misreported as a transport error.

Extract the shared classification logic into raise_for_botocore_error() in
auth.py to avoid duplicating it between user.py and auth.py.
Copilot AI review requested due to automatic review settings August 11, 2026 21:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e082d61f07

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/otf_api/exceptions.py
@NodeJSmith
NodeJSmith enabled auto-merge (squash) August 11, 2026 21:08
Copilot AI review requested due to automatic review settings August 11, 2026 21:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@NodeJSmith
NodeJSmith merged commit 1c8321d into main Aug 11, 2026
4 checks passed
@NodeJSmith
NodeJSmith deleted the 141 branch August 11, 2026 21:18

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 28f6ce232a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/otf_api/auth/user.py
raise OtfAuthenticationError(str(e)) from e
raise OtfAuthenticationError("OTF authentication failed") from e
except BotoCoreError as e:
raise_for_botocore_error(e, "authenticating with Cognito")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the transport-error contract for Cognito failures

When a botocore connectivity failure occurs during OtfUser construction, this new branch raises OtfTransportError immediately with a botocore exception as its cause. However, docs/guides/error-handling.md still states that transport errors are automatically retried and always wrap httpx; neither is true here because the retry decorator only covers OtfClient.do(), after user construction. Update the public reference to describe the botocore cause and qualify which transport errors are retried.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Complete OtfUser's public error boundary

2 participants