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

[IND-458]: In case of errors in comlink log request #722

Merged
merged 1 commit into from
Oct 31, 2023

Conversation

Christopher-Li
Copy link
Contributor

Changelist

Log request in comlink in case of errors

Test Plan

Verifies that the query and parameters correct print out

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 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.

@linear
Copy link

linear bot commented Oct 29, 2023

IND-458 In case of errors in comlink log request

When we encounter errors in comlink, it is very useful to get access to the request that threw an error in the indexer to debug.

There shouldn't be any PII in comlink since the indexer is a read only service.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 29, 2023

Walkthrough

The changes primarily involve the addition of the req (request) parameter to various error handling function calls across multiple controller files in the indexer/services/comlink/src/controllers/api/v4/ directory. This allows the error handling functions to access the request object. Additionally, two exported functions in helpers.ts have been modified to accept req as an additional parameter and include its params and query properties in the error log.

Changes

File Path Summary
.../api/v4/addresses-controller.ts Added req parameter to two error handling function calls in router.get().
.../api/v4/asset-positions-controller.ts Added req parameter to the error handling function in AssetPositionsController GET / route.
.../api/v4/candles-controller.ts Added req parameter to the CandlesController GET /perpetualMarkets/:ticker route handler function.
.../api/v4/compliance-controller.ts Added req parameter to the error handling function in ComplianceController GET / route.
.../api/v4/fills-controller.ts Added req parameter to the error handling function in FillsController GET / route.
.../api/v4/height-controller.ts Replaced _req with req in route handler function and added req to error handling function.
.../api/v4/historical-funding-controller.ts Added req parameter to the error handling function in HistoricalFundingController GET / route.
.../api/v4/historical-pnl-controller.ts Added req parameter to the error handling function in HistoricalPnlController GET / route.
.../api/v4/orderbook-controller.ts Added req parameter to the error handling function in OrderbooksController GET /perpetualMarket/:ticker route.
.../api/v4/orders-controller.ts Added req parameter to error handling functions in GET / and GET /:orderId routes.
.../api/v4/perpetual-markets-controller.ts Added req parameter to the error handling function in PerpetualMarketController GET / route.
.../api/v4/perpetual-positions-controller.ts Added req parameter to the error handling function in router.get method.
.../api/v4/sparklines-controller.ts Added req parameter to the error handling function in SparklinesController GET / route.
.../api/v4/trades-controller.ts Added req parameter to the error handling function in TradesController GET /perpetualMarket/:ticker route.
.../api/v4/transfers-controller.ts Added req parameter to the error handling function in TransfersController GET / route.
.../src/lib/helpers.ts Modified handleControllerError and handleInternalServerError functions to accept req and include its params and query in error log.

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai help to get help.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.json

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.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 0ba123e and 52585b4.
Files selected for processing (16)
  • indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts (2 hunks)
  • indexer/services/comlink/src/controllers/api/v4/asset-positions-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/candles-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/compliance-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/fills-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/height-controller.ts (2 hunks)
  • indexer/services/comlink/src/controllers/api/v4/historical-funding-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/historical-pnl-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/orderbook-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/orders-controller.ts (2 hunks)
  • indexer/services/comlink/src/controllers/api/v4/perpetual-markets-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/perpetual-positions-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/sparklines-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/trades-controller.ts (1 hunks)
  • indexer/services/comlink/src/controllers/api/v4/transfers-controller.ts (1 hunks)
  • indexer/services/comlink/src/lib/helpers.ts (4 hunks)
Files skipped from review due to trivial changes (12)
  • indexer/services/comlink/src/controllers/api/v4/asset-positions-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/candles-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/compliance-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/height-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/historical-funding-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/historical-pnl-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/orderbook-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/orders-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/perpetual-positions-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/sparklines-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/trades-controller.ts
  • indexer/services/comlink/src/controllers/api/v4/transfers-controller.ts
Additional comments: 8
indexer/services/comlink/src/controllers/api/v4/perpetual-markets-controller.ts (1)
  • 142-147: The addition of the req parameter to the handleControllerError function call is a good practice. It will provide more context about the request that led to the error, which can be useful for debugging. Ensure that the handleControllerError function has been updated to handle this new parameter appropriately.
indexer/services/comlink/src/controllers/api/v4/fills-controller.ts (1)
  • 161-166: The handleControllerError function now includes the req parameter. Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, verify that the handleControllerError function correctly handles the req parameter and does not expose sensitive information from the request object in the error logs.
indexer/services/comlink/src/controllers/api/v4/addresses-controller.ts (2)
  • 269-274: The req object is now being passed to the handleControllerError function. This will provide more context when logging errors. Ensure that the handleControllerError function is properly handling the req object.

  • 309-314: The req object is now being passed to the handleControllerError function. This will provide more context when logging errors. Ensure that the handleControllerError function is properly handling the req object.

indexer/services/comlink/src/lib/helpers.ts (4)
  • 48-53: The handleControllerError function now accepts an additional req parameter of type express.Request. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 58-63: The handleControllerError function now includes the req parameter in its call to handleInternalServerError. Ensure that all calls to handleControllerError are updated to include the req parameter.

  • 67-72: The handleInternalServerError function now accepts an additional req parameter of type express.Request. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.

  • 79-84: The handleInternalServerError function now includes the params and query properties of req in the error log. This is a good practice as it provides more context about the request that led to the error.

@Christopher-Li Christopher-Li merged commit cb8e3a1 into main Oct 31, 2023
11 checks passed
@Christopher-Li Christopher-Li deleted the cl_log_request branch October 31, 2023 17:10
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.

3 participants