Skip to content

Allow to specify client provider ID at client registration#564

Merged
byewokko merged 3 commits intomainfrom
feature/configurable-provider-id-for-new-client
Mar 19, 2026
Merged

Allow to specify client provider ID at client registration#564
byewokko merged 3 commits intomainfrom
feature/configurable-provider-id-for-new-client

Conversation

@byewokko
Copy link
Copy Markdown
Collaborator

@byewokko byewokko commented Mar 19, 2026

Summary by CodeRabbit

  • New Features

    • Users can now specify a preferred provider ID when registering a client, enabling greater control over provider selection.
  • Bug Fixes

    • Enhanced error handling during client registration to validate provider editability and prevent registration attempts with non-editable providers.

@byewokko byewokko self-assigned this Mar 19, 2026
@byewokko byewokko added the bug Something isn't working label Mar 19, 2026
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 19, 2026

Warning

Rate limit exceeded

@byewokko has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 19 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 67eaace5-0d5c-4410-bcb4-34a7416d9016

📥 Commits

Reviewing files that changed from the base of the PR and between 423839d and 9dceabf.

📒 Files selected for processing (1)
  • seacatauth/client/handler.py
📝 Walkthrough

Walkthrough

This pull request adds support for specifying a client provider ID during client registration. Changes include adding an optional provider_id field to the client registration schema, validating that the provider is editable before client creation, and handling non-editable provider errors at the request handler level.

Changes

Cohort / File(s) Summary
Client Schema & Configuration
seacatauth/client/schema.py
Added optional provider_id property to REGISTER_CLIENT request schema to allow specifying a preferred provider during client registration.
Client Service Logic
seacatauth/client/service.py
Added validation in create_client to check provider.Editable and raise NotEditableError if provider is not editable; changed exception type for unknown provider from ValueError to KeyError.
Client Request Handler
seacatauth/client/handler.py
Added exception handling in register_client to catch NotEditableError and immediately return the error response without propagating the exception.
Release Documentation
CHANGELOG.md
Added v25.48-alpha23 pre-release entry documenting the ability to specify client provider ID at registration.

Sequence Diagram

sequenceDiagram
    participant Client
    participant Handler as register_client Handler
    participant Service as ClientService
    participant Provider
    
    Client->>Handler: POST with provider_id in JSON
    Handler->>Service: create_client(**json_data)
    
    alt Provider not editable
        Service->>Provider: Check provider.Editable
        Provider-->>Service: Editable = False
        Service-->>Handler: raise NotEditableError
        Handler-->>Client: Return error response (json_response)
    else Provider is editable
        Service->>Provider: Check provider.Editable
        Provider-->>Service: Editable = True
        Service->>Service: Generate client ID
        Service->>Provider: create_client()
        Provider-->>Service: Client created
        Service-->>Handler: Client object
        Handler->>Handler: Fetch client, normalize data
        Handler-->>Client: Return normalized client data
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

enhancement

Suggested reviewers

  • mejroslav

Poem

🐰 A provider ID now finds its way,
Through schema, service, handler's relay,
Checking editability with care,
Registration flows beyond compare! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Allow to specify client provider ID at client registration' accurately and concisely summarizes the primary change—adding a new optional provider_id parameter to the client registration schema.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/configurable-provider-id-for-new-client
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
CHANGELOG.md (1)

32-32: Use clearer wording for this fix entry.

Consider changing to “Allow specifying client provider ID at client registration” for cleaner grammar and consistency with the rest of the list.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@CHANGELOG.md` at line 32, Replace the changelog entry text "Allow to specify
client provider ID at client registration" with the clearer phrasing "Allow
specifying client provider ID at client registration" so the grammar matches
other list items; locate the exact string in CHANGELOG.md and update it
accordingly.
seacatauth/client/service.py (1)

226-226: Consider using a more specific exception type for unknown provider.

Using a raw KeyError works but loses semantic clarity. A dedicated exception (e.g., ProviderNotFoundError or reusing ClientNotFoundError with a different message) would be more consistent with the codebase's error handling patterns and easier to handle explicitly in the handler layer.

This is not blocking since the handler should catch KeyError anyway, but it would improve API consistency.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@seacatauth/client/service.py` at line 226, Replace the raw KeyError raised
for unknown provider with a dedicated exception type to improve semantic
clarity: define a new ProviderNotFoundError (or reuse ClientNotFoundError if
appropriate) and change the raise in the method that currently does raise
KeyError("No client provider with ID {!r} is registered.".format(provider_id))
to raise ProviderNotFoundError(provider_id) or a message-bearing instance; then
update any call sites/handlers that expect KeyError to catch the new
ProviderNotFoundError (or both) so error handling remains correct.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@seacatauth/client/handler.py`:
- Around line 139-142: The handler currently only catches
exceptions.NotEditableError from the call to ClientService.create_client and
lets a KeyError (raised for unknown provider_id) bubble up; update the
try/except around ClientService.create_client to also catch KeyError and return
a proper client error response (e.g., a 400 Bad Request or 404 with a
descriptive message) instead of raising a 500; reference the existing
exceptions.NotEditableError handling pattern and ensure the new KeyError branch
produces a JSON HTTP error response for the request.

---

Nitpick comments:
In `@CHANGELOG.md`:
- Line 32: Replace the changelog entry text "Allow to specify client provider ID
at client registration" with the clearer phrasing "Allow specifying client
provider ID at client registration" so the grammar matches other list items;
locate the exact string in CHANGELOG.md and update it accordingly.

In `@seacatauth/client/service.py`:
- Line 226: Replace the raw KeyError raised for unknown provider with a
dedicated exception type to improve semantic clarity: define a new
ProviderNotFoundError (or reuse ClientNotFoundError if appropriate) and change
the raise in the method that currently does raise KeyError("No client provider
with ID {!r} is registered.".format(provider_id)) to raise
ProviderNotFoundError(provider_id) or a message-bearing instance; then update
any call sites/handlers that expect KeyError to catch the new
ProviderNotFoundError (or both) so error handling remains correct.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e41af8bf-4001-4638-979a-b6294e67360d

📥 Commits

Reviewing files that changed from the base of the PR and between 69465b2 and 423839d.

📒 Files selected for processing (4)
  • CHANGELOG.md
  • seacatauth/client/handler.py
  • seacatauth/client/schema.py
  • seacatauth/client/service.py

Comment thread seacatauth/client/handler.py
@byewokko byewokko merged commit 2558a9e into main Mar 19, 2026
8 checks passed
@byewokko byewokko deleted the feature/configurable-provider-id-for-new-client branch March 19, 2026 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant