Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bug with socks subaccount subscription with best effort canceled logic. #2718

Merged
merged 7 commits into from
Feb 10, 2025

Conversation

vincentwschau
Copy link
Contributor

@vincentwschau vincentwschau commented Feb 7, 2025

Changelist

Fix typo + add test to catch issues with subscribing to subaccount orders initial response.

Test Plan

Unit tests, tested in staging.

Author/Reviewer Checklist

  • If this PR has changes that result in a different app state given the same prior state and transaction list, manually add the state-breaking label.
  • If the PR has breaking postgres changes to the indexer add the indexer-postgres-breaking label.
  • If this PR isn't state-breaking but has changes that modify behavior in PrepareProposal or ProcessProposal, manually add the label proposal-breaking.
  • If this PR is one of many that implement a specific feature, manually label them all feature:[feature-name].
  • If you wish to for mergify-bot to automatically create a PR to backport your change to a release branch, manually add the label backport/[branch-name].
  • Manually add any of the following labels: refactor, chore, bug.

Summary by CodeRabbit

  • New Features
    • Introduced two optional filtering parameters for order listings, allowing for more precise query results.
  • Improvements
    • Enhanced parameter validation to ensure accurate filtering.
    • Strengthened subscription response reliability with refined URL handling and improved error tracking.

@vincentwschau vincentwschau requested a review from a team as a code owner February 7, 2025 23:48
Copy link
Contributor

coderabbitai bot commented Feb 7, 2025

Walkthrough

This pull request introduces new optional query parameters to order listing endpoints, enhancing the filtering capabilities of the API without impacting existing functionality. It also tightens URL matching in tests and adds error logging with a corrected URL interpolation in the subscription service, ensuring more reliable handling of subscription responses.

Changes

File(s) Change summary
indexer/.../api/v4/orders-controller.ts Added two new optional query parameters: goodTilBlockAfter (integer > 0) and goodTilBlockTimeAfter (ISO8601 string) with an updated validation schema for order endpoints.
indexer/.../subscriptions.test.ts Updated regex patterns to require an equal sign and a digit sequence for the goodTilBlockAfter parameter in URL patterns for both accounts and parent subaccount channels.
indexer/.../subscription.ts Enhanced error logging in subscription methods and corrected URL string interpolation for goodTilBlockAfter (changed from "$$" to "$") to ensure proper evaluation in requests.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant OC as OrdersController
    participant Service as Subscription Service

    Client->>OC: GET /orders?goodTilBlockAfter=&goodTilBlockTimeAfter=
    OC->>Service: Forward request with query parameters
    Service-->>OC: Return filtered order data
    OC-->>Client: Respond with order data
Loading
sequenceDiagram
    participant Sub as Subscriptions
    participant Axios as Axios Request
    participant Logger as Error Logger

    Sub->>Axios: Make GET request with URL including goodTilBlockAfter
    alt Successful response
        Axios-->>Sub: Return response data
        Sub-->>Client: Send data to client
    else Error encountered
        Axios-->>Sub: Return error
        Sub->>Logger: Log error with context details
        Sub-->>Client: Return error response
    end
Loading

Possibly related PRs

Suggested reviewers

  • tqin7
  • vincentwschau

Poem

I'm a rabbit hopping with glee,
New filters in the code, as fine as can be,
Query hops and correct URL streams,
Logging errors and hopping dreams,
Together we code, in carrot-filled delight,
Hop on, hop on—let's code through the night!
🐰🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d425749 and 6a2339f.

📒 Files selected for processing (3)
  • indexer/services/comlink/src/controllers/api/v4/orders-controller.ts (1 hunks)
  • indexer/services/socks/__tests__/lib/subscriptions.test.ts (2 hunks)
  • indexer/services/socks/src/lib/subscription.ts (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (12)
  • GitHub Check: call-build-ecs-service-vulcan / (vulcan) Check docker image build
  • GitHub Check: call-build-ecs-service-socks / (socks) Check docker image build
  • GitHub Check: call-build-ecs-service-roundtable / (roundtable) Check docker image build
  • GitHub Check: call-build-ecs-service-ender / (ender) Check docker image build
  • GitHub Check: call-build-ecs-service-comlink / (comlink) Check docker image build
  • GitHub Check: check-build-auxo
  • GitHub Check: check-build-bazooka
  • GitHub Check: test / run_command
  • GitHub Check: run_command
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Summary
🔇 Additional comments (5)
indexer/services/socks/__tests__/lib/subscriptions.test.ts (1)

62-63: LGTM! URL patterns are now more strictly defined.

The URL patterns for both V4_ACCOUNTS and V4_PARENT_ACCOUNTS channels now correctly enforce that the goodTilBlockAfter parameter must be followed by numeric values, improving the validation of subscription URLs.

Also applies to: 71-72

indexer/services/comlink/src/controllers/api/v4/orders-controller.ts (1)

495-501: LGTM! New query parameters are well-defined and properly validated.

The new optional parameters goodTilBlockAfter and goodTilBlockTimeAfter are added with appropriate validation rules:

  • goodTilBlockAfter is validated as a positive integer
  • goodTilBlockTimeAfter is validated as an ISO8601 string

Also applies to: 507-511

indexer/services/socks/src/lib/subscription.ts (3)

590-591: LGTM! URL construction is improved with proper string interpolation.

The URL construction now correctly uses string interpolation and ensures a positive block height value using Math.max(numBlockHeight - 20, 1).


611-616: LGTM! Comprehensive error logging added for subscription failures.

Error logging now includes all relevant details (method name, message, subscription ID, and error) to help with debugging subscription issues.


703-708: LGTM! Consistent error logging added for parent subaccount subscription failures.

Error logging for parent subaccount subscriptions follows the same comprehensive pattern, maintaining consistency in error handling.

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ 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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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.

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. (Beta)
  • @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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@vincentwschau vincentwschau merged commit a601005 into main Feb 10, 2025
16 checks passed
@vincentwschau vincentwschau deleted the vincentc/debug-socks branch February 10, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants