Skip to content

feat: add RateLimitException for NameCom adapter#61

Merged
ChiragAgg5k merged 1 commit intomasterfrom
add-rate-limit-exception
Mar 2, 2026
Merged

feat: add RateLimitException for NameCom adapter#61
ChiragAgg5k merged 1 commit intomasterfrom
add-rate-limit-exception

Conversation

@ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Mar 2, 2026

Summary

This PR adds support for detecting and handling rate limit errors from the NameCom API.

Changes

  • New Exception: Added RateLimitException class to handle HTTP 429 rate limit errors
  • Adapter Updates: Updated NameCom adapter to:
    • Detect HTTP 429 status codes
    • Detect error messages containing "Rate Limit Exceeded"
    • Throw RateLimitException when rate limits are hit
  • Refactoring: Reorganized exception handling in all methods to catch RateLimitException first before generic Exception

Technical Details

  • Added ERROR_RATE_LIMIT_EXCEEDED constant with value "Rate Limit Exceeded"
  • Added entry to ERROR_MAP with HTTP code 429
  • Updated exception handling in methods: getPrice, purchase, transfer, getDomain, updateDomain, renew, getAuthCode, checkTransferStatus, updateNameservers

Testing

Rate limit exceptions are now properly caught and thrown, allowing applications to handle rate limiting appropriately (e.g., implement backoff strategies).

Summary by CodeRabbit

Release Notes

  • Bug Fixes

    • Improved rate-limit error handling across domain management operations to detect and properly communicate when API rate limits are exceeded.
    • Enhanced error propagation to ensure rate-limit scenarios are consistently handled throughout the registrar.
  • Improvements

    • Streamlined pricing retrieval and caching logic for improved consistency.

- Add new RateLimitException class to handle API rate limit errors
- Update NameCom adapter to detect HTTP 429 and 'Rate Limit Exceeded' messages
- Refactor exception handling to catch RateLimitException first before generic Exception
- Add ERROR_RATE_LIMIT_EXCEEDED constant to error map
@ChiragAgg5k ChiragAgg5k force-pushed the add-rate-limit-exception branch from 18ce9f8 to 9d7e2bd Compare March 2, 2026 11:05
@coderabbitai
Copy link

coderabbitai bot commented Mar 2, 2026

Walkthrough

This pull request introduces rate-limit exception handling to the NameCom registrar adapter. A new RateLimitException class is created to represent rate-limit scenarios. The NameCom adapter is updated to detect HTTP 429 responses and rate-limit messages, throwing the new exception when encountered. The ERROR_MAP constant is extended with a rate-limit mapping, and multiple method-level catch blocks are added to propagate rate-limit exceptions. Additionally, pricing logic is refactored to use a unified price map approach, and error handling is enhanced across domain retrieval, update, renewal, transfer status, and auth code operations.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 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 pull request title 'feat: add RateLimitException for NameCom adapter' accurately and concisely describes the main changes: introducing a new RateLimitException and integrating it into the NameCom adapter.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-rate-limit-exception

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

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Domains/Registrar/Adapter/NameCom.php`:
- Around line 368-370: Cached entries for a reg type can be coerced to zero and
returned as new Price(...) leading to Price(0) instead of throwing
PriceNotFoundException; update the caching and lookup in NameCom (check the
$cached array for $regType and the presence/validity of the 'price'/'premium'
keys) so you never store or accept missing/invalid prices (do not cache
null/missing values), and when the cached entry is absent or its 'price' is not
set/valid, throw PriceNotFoundException instead of returning Price(0); adjust
the code paths that write the cache to skip saving missing prices and the lookup
that constructs new Price($cached[$regType]['price'],
$cached[$regType]['premium']) to validate keys first.

ℹ️ Review info

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a14b7a2 and 9d7e2bd.

📒 Files selected for processing (2)
  • src/Domains/Registrar/Adapter/NameCom.php
  • src/Domains/Registrar/Exception/RateLimitException.php

@ChiragAgg5k ChiragAgg5k merged commit 4f9191c into master Mar 2, 2026
7 checks passed
@ChiragAgg5k ChiragAgg5k deleted the add-rate-limit-exception branch March 2, 2026 11:15
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.

2 participants