Skip to content

Conversation

johnsoter13
Copy link
Contributor

COMPLETES #< INSERT LINK TO ISSUE >

This pull request addresses

  • Current u2c logic doesn't support update to u2c backend that marks some service urls with a negative priority (-1)

by making the following changes

  • Updating filter function when looking for the priority host that removes urls with negative priority as well as hosts that are marked as failed (current logic only looks if url is marked as failed)

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

Manually tested, and tests written

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

I certified that

  • I have read and followed contributing guidelines
  • I discussed changes with code owners prior to submitting this pull request
  • I have not skipped any automated checks
  • All existing and new tests passed
  • I have updated the documentation accordingly

Make sure to have followed the contributing guidelines before submitting.

@johnsoter13 johnsoter13 requested review from a team as code owners July 29, 2025 15:56
Copy link
Contributor

coderabbitai bot commented Jul 29, 2025

📝 Walkthrough

Walkthrough

The changes modify the logic in the host selection process within the service URL handling code to ensure that only hosts with a positive priority are considered when determining the highest-priority host. Specifically, the reduce function now includes an explicit check for the current host's priority being greater than zero before it can be selected. Additionally, a new integration test was added to verify that hosts with a priority of -1 are correctly ignored in host selection, ensuring that only valid hosts are returned by the service URL resolution logic.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3d43b1 and 9450eee.

📒 Files selected for processing (1)
  • packages/@webex/webex-core/test/integration/spec/services/services.js (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/@webex/webex-core/test/integration/spec/services/services.js
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Initialize Project
  • GitHub Check: AWS Amplify Console Web Preview
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@johnsoter13 johnsoter13 added the validated If the pull request is validated for automation. label Jul 29, 2025
Copy link

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-4416.d3m3l2kee0btzx.amplifyapp.com

Copy link
Contributor

@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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3389494 and f3d43b1.

📒 Files selected for processing (2)
  • packages/@webex/webex-core/src/lib/services/service-url.js (1 hunks)
  • packages/@webex/webex-core/test/integration/spec/services/services.js (1 hunks)
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: robstax
PR: webex/webex-js-sdk#3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in `packages/@webex/webex-core/test/unit/spec/webex-core.js`, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.
packages/@webex/webex-core/src/lib/services/service-url.js (1)

Learnt from: robstax
PR: #3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in packages/@webex/webex-core/test/unit/spec/webex-core.js, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.

packages/@webex/webex-core/test/integration/spec/services/services.js (1)

Learnt from: robstax
PR: #3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in packages/@webex/webex-core/test/unit/spec/webex-core.js, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.

🧬 Code Graph Analysis (1)
packages/@webex/webex-core/test/integration/spec/services/services.js (1)
packages/@webex/webex-core/src/lib/services/service-url.js (1)
  • ServiceUrl (9-123)
🪛 GitHub Actions: johnsoter13 is running Pull Request CI
packages/@webex/webex-core/test/integration/spec/services/services.js

[error] 343-343: ReferenceError: negativePriorityUrl is not defined in test case 'handles case where there is a priority of -1 for a service url' in #getServiceFromUrl()

🔇 Additional comments (2)
packages/@webex/webex-core/src/lib/services/service-url.js (1)

78-80: LGTM! Clean implementation of negative priority filtering.

The addition of current.priority > 0 && to the reduce condition effectively filters out hosts with zero or negative priority from being selected as the priority host. This aligns perfectly with the PR objective to handle u2c backend updates that mark some service URLs with negative priority (-1).

The logic ensures that only hosts with positive priority are considered in the priority selection algorithm, while maintaining the existing priority comparison and homeCluster fallback behavior.

packages/@webex/webex-core/test/integration/spec/services/services.js (1)

324-355: Well-designed test case for negative priority filtering.

The test effectively validates the core functionality by:

  • Creating a ServiceUrl with both positive (1) and negative (-1) priority hosts
  • Verifying that the host with negative priority is correctly ignored
  • Confirming that the host with positive priority is selected as the priority URL

This test case provides good coverage for the changes made in the service-url.js file and aligns with the PR objectives.

Copy link
Contributor

@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: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3389494 and f3d43b1.

📒 Files selected for processing (2)
  • packages/@webex/webex-core/src/lib/services/service-url.js (1 hunks)
  • packages/@webex/webex-core/test/integration/spec/services/services.js (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: robstax
PR: webex/webex-js-sdk#3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in `packages/@webex/webex-core/test/unit/spec/webex-core.js`, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.
packages/@webex/webex-core/test/integration/spec/services/services.js (1)

Learnt from: robstax
PR: #3948
File: packages/@webex/webex-core/test/unit/spec/webex-core.js:178-254
Timestamp: 2024-11-01T00:30:53.442Z
Learning: In the webex-js-sdk project, when reviewing changes in packages/@webex/webex-core/test/unit/spec/webex-core.js, if the user declines to add negative test cases for invalid interceptor configurations, accept their decision and do not insist.

🪛 GitHub Actions: johnsoter13 is running Pull Request CI
packages/@webex/webex-core/test/integration/spec/services/services.js

[error] 343-343: ReferenceError: negativePriorityUrl is not defined in test case 'handles case where there is a priority of -1 for a service url' in #getServiceFromUrl()

🔇 Additional comments (2)
packages/@webex/webex-core/src/lib/services/service-url.js (1)

78-80: LGTM! Correctly filters out negative priority hosts.

The addition of current.priority > 0 check ensures that hosts with negative priority values (like -1) are excluded from selection during the reduce operation. This aligns perfectly with the PR objective to filter out URLs with negative priority from the u2c backend.

packages/@webex/webex-core/test/integration/spec/services/services.js (1)

324-355: Test correctly verifies negative priority filtering logic.

The test properly validates that hosts with priority -1 are ignored during host selection, ensuring only hosts with positive priority are considered. This effectively tests the logic change made in service-url.js.

@@ -75,7 +75,9 @@ const ServiceUrl = AmpState.extend({
return this._generateHostUrl(
filteredHosts.reduce(
(previous, current) =>
previous.priority > current.priority || !previous.homeCluster ? current : previous,
current.priority > 0 && (previous.priority > current.priority || !previous.homeCluster)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think we need to do a couple more things

  1. homeCluster should not override priority decisions (this is a problem with the current implementation)
  2. the array probably needs to be pre-sorted by priority

As it is right now, -1 urls would be removed, but we could still have a logic error based on the following
A. If homeCluster is set to true for an "invalid" FQDN
B. if the order of the array is incorrect

Copy link
Collaborator

Choose a reason for hiding this comment

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

I also think we need Colin's input on this re: homeCluster since he added this part

Copy link
Contributor

Choose a reason for hiding this comment

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

did we decide we don't have to do these? i thought we could merge this as is?

@chrisadubois
Copy link
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validated If the pull request is validated for automation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants