Repository navigation
Fix: Saving errors status in cache - #28
Conversation
WalkthroughThe changes introduce centralized debug logging in the Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. ✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
lib/ontologies_api_client/request_federation.rb (1)
31-37: Fixed portal-specific parameter handling and caching behaviorThis change addresses the core issue described in the PR by:
- Using portal-specific parameters when available (
params[portal_name.to_s.downcase])- Conditionally caching portal down status only when the call is not internal
The selective caching prevents the current portal's errors from being cached for 10 minutes, which was blocking access unnecessarily.
However, there's an unused exception variable that should be addressed:
- rescue Exception => e + rescue Exception🧰 Tools
🪛 RuboCop (1.73)
[warning] 33-33: Useless assignment to variable -
e.(Lint/UselessAssignment)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (2)
lib/ontologies_api_client/http.rb(4 hunks)lib/ontologies_api_client/request_federation.rb(3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
lib/ontologies_api_client/request_federation.rb (1)
lib/ontologies_api_client/http.rb (4)
log(165-167)get(61-102)conn(46-55)delete(153-159)
🪛 RuboCop (1.73)
lib/ontologies_api_client/request_federation.rb
[warning] 33-33: Useless assignment to variable - e.
(Lint/UselessAssignment)
🔇 Additional comments (6)
lib/ontologies_api_client/http.rb (2)
80-80: Improved logging implementation using centralized methodThe changes replace direct
putsstatements with calls to the new centralizedlogmethod, ensuring consistent debugging output throughout the HTTP client.Also applies to: 98-98, 154-154
165-167: Good addition of a centralized logging methodThe addition of a centralized
logmethod improves code organization and maintainability by:
- Providing a single point of control for debug output
- Consistently checking the debug flag before printing
- Making it easier to modify logging behavior in the future
This change complements the related improvements in the federation request handling.
lib/ontologies_api_client/request_federation.rb (4)
25-26: Improved error logging for down portalsChanged to use the centralized logging method which provides consistent debug output handling.
45-47: Good extraction of helper method for federation portal namesThe new helper method
federated_portals_namesfollows the DRY principle by extracting the common logic for retrieving federation portal names.
49-53: Improved request portals methodThe updated
request_portalsmethod now uses the new helper method and properly removes the:federateparameter from params, preventing it from being passed to the API.
65-67: Good addition of internal call detection methodThe new
internal_call?method determines if a connection is for the current portal by comparing URL prefixes. This is a crucial part of fixing the caching issue, as it prevents caching errors for the current portal.
Fixes agroportal/project-management#712. In the scope of the federation work (#24), we introduced a status cache to store the availability of federated portals. If a portal is down, its status is cached for 10 minutes to avoid unnecessary requests. However, the issue was that errors from the current portal were also cached, unintentionally blocking it for 10 minutes and requiring to clear the cache.
Summary by CodeRabbit
New Features
Refactor