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

chore: add receivedAt and requestIP in payload [PIPE-1135] #4764

Merged
merged 2 commits into from
Jun 6, 2024

Conversation

BonapartePC
Copy link
Contributor

@BonapartePC BonapartePC commented Jun 6, 2024

Description

add receivedAt and requestIP in payload for internal batch endpoint.

Linear Ticket

https://linear.app/rudderstack/issue/PIPE-1135/[rudder-server]-fix-internalreplay-endpoint-to-start-honouring

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features
    • Improved event payload handling by automatically adding receivedAt and requestIP fields if they are missing. This ensures more accurate and complete data processing.

@BonapartePC BonapartePC changed the title add receivedAt and requestIP in payload [PIPE-1135] chore: add receivedAt and requestIP in payload [PIPE-1135] Jun 6, 2024
Copy link
Contributor

coderabbitai bot commented Jun 6, 2024

Walkthrough

The recent changes introduce new functionalities to the Gateway component, specifically focusing on enhancing the handling of event payloads. Two new functions, fillReceivedAt and fillRequestIP, are added to ensure that the receivedAt timestamp and requestIP are present in the payload. Corresponding tests are added to verify these enhancements, ensuring robustness and correctness in different scenarios.

Changes

File Change Summary
gateway/gateway_test.go Introduced a new context extractJobsFromInternalBatchPayload in the test suite to handle scenarios where receivedAt and requestIP properties are either present or need to be added.
gateway/handle.go Added fillReceivedAt and fillRequestIP functions to manipulate event payloads by adding missing fields. These functions are invoked within extractJobsFromInternalBatchPayload method.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant Client
    participant Gateway
    participant PayloadHandler

    Client->>Gateway: Send event payload
    Gateway->>PayloadHandler: Check and fill `receivedAt`
    PayloadHandler-->>Gateway: Return modified payload
    Gateway->>PayloadHandler: Check and fill `requestIP`
    PayloadHandler-->>Gateway: Return modified payload
    Gateway->>Client: Acknowledge receipt
Loading

Poem

In the world of code so bright,
Events now shine with added light,
receivedAt and requestIP in tow,
Ensuring every payload's glow.
Tests confirm the paths we tread,
Robust and clear, no need to dread.
🎉✨ Code Rabbit celebrates, all said! 🌟🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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

Copy link

codecov bot commented Jun 6, 2024

Codecov Report

Attention: Patch coverage is 71.42857% with 4 lines in your changes missing coverage. Please review.

Project coverage is 74.64%. Comparing base (d9884fd) to head (e77520f).

Current head e77520f differs from pull request most recent head 59e429a

Please upload reports for the commit 59e429a to get more accurate results.

Files Patch % Lines
gateway/handle.go 71.42% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4764      +/-   ##
==========================================
- Coverage   74.69%   74.64%   -0.06%     
==========================================
  Files         414      414              
  Lines       48606    48620      +14     
==========================================
- Hits        36308    36290      -18     
- Misses       9923     9954      +31     
- Partials     2375     2376       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

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 UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d9884fd and e77520f.

Files selected for processing (2)
  • gateway/gateway_test.go (2 hunks)
  • gateway/handle.go (2 hunks)
Additional context used
golangci-lint
gateway/handle.go

81-81: undefined: userWorkerBatchRequestT (typecheck)


82-82: undefined: batchUserWorkerBatchRequestT (typecheck)


83-83: undefined: RequestHandler (typecheck)


84-84: undefined: RequestHandler (typecheck)


90-90: undefined: userWebRequestWorkerT (typecheck)


132-132: undefined: userWebRequestWorkerT (typecheck)


148-148: undefined: userWebRequestWorkerT (typecheck)


180-180: undefined: userWebRequestWorkerT (typecheck)


275-275: undefined: webRequestT (typecheck)


162-162: undefined: batchWebRequestT (typecheck)


183-183: undefined: webRequestT (typecheck)


188-188: undefined: sourceDebugger (typecheck)


194-194: gw.NewSourceStat undefined (type *Handle has no field or method NewSourceStat) (typecheck)


201-201: undefined: errRequestDropped (typecheck)


204-204: undefined: errRequestSuppressed (typecheck)


220-220: undefined: sourceDebugger (typecheck)


234-234: undefined: userWorkerBatchRequestT (typecheck)


303-303: undefined: jobFromReq (typecheck)


316-316: undefined: batchEvent (typecheck)


379-379: undefined: semverRegexp (typecheck)


442-442: undefined: errRequestDropped (typecheck)


447-447: undefined: errRequestSuppressed (typecheck)


509-509: undefined: customVal (typecheck)


521-521: undefined: extractEvent (typecheck)


535-535: undefined: delimiter (typecheck)


631-631: undefined: webRequestT (typecheck)


677-677: gw.newReqTypeStatsTagsWithReason undefined (type *Handle has no field or method newReqTypeStatsTagsWithReason) (typecheck)


684-684: gw.newReqTypeStatsTagsWithReason undefined (type *Handle has no field or method newReqTypeStatsTagsWithReason) (typecheck)


703-703: gw.newReqTypeStatsTagsWithReason undefined (type *Handle has no field or method newReqTypeStatsTagsWithReason) (typecheck)


721-721: gw.newReqTypeStatsTagsWithReason undefined (type *Handle has no field or method newReqTypeStatsTagsWithReason) (typecheck)


792-792: gw.newSourceStatTagsWithReason undefined (type *Handle has no field or method newSourceStatTagsWithReason) (typecheck)


851-851: undefined: customVal (typecheck)

Additional comments not posted (1)
gateway/gateway_test.go (1)

1898-1990: Ensure correct handling of receivedAt and requestIP in payloads.

The tests in the extractJobsFromInternalBatchPayload context correctly verify that the receivedAt and requestIP fields are not overridden if they already exist in the payload, and are added if they are absent. This aligns with the PR's objective to manage these fields appropriately.

gateway/handle.go Show resolved Hide resolved
gateway/handle.go Show resolved Hide resolved
gateway/gateway_test.go Outdated Show resolved Hide resolved
@BonapartePC BonapartePC enabled auto-merge (squash) June 6, 2024 09:09
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: 0

Outside diff range and nitpick comments (5)
gateway/gateway_test.go (5)

Line range hint 2135-2135: The function withContentType is undefined in the provided context. Ensure that this function is either implemented or imported correctly.


Line range hint 1416-1416: The type webRequestT is undefined in the provided context. Ensure that this type is either defined or imported correctly to avoid compilation errors.

Also applies to: 1429-1429, 1453-1453, 1475-1475, 1499-1499, 1536-1536, 1558-1558, 1581-1581, 1605-1605, 1617-1617


Line range hint 246-246: The type Handle is undefined in the provided context. Ensure that this type is either defined or imported correctly to avoid compilation errors.

Also applies to: 281-281, 416-416, 427-427, 449-449, 535-535, 544-544, 568-568, 870-870


Line range hint 229-229: The function getUsersPayload is undefined in the provided context. Ensure that this function is either implemented or imported correctly.


Line range hint 568-568: The variable customVal is undefined in the provided context. Ensure that this variable is either defined or imported correctly to avoid runtime errors.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e77520f and 59e429a.

Files selected for processing (1)
  • gateway/gateway_test.go (2 hunks)
Additional context used
golangci-lint
gateway/gateway_test.go

2098-2098: undefined: Handle (typecheck)


2151-2151: undefined: Handle (typecheck)


229-229: undefined: getUsersPayload (typecheck)


246-246: undefined: Handle (typecheck)


281-281: undefined: Handle (typecheck)


416-416: undefined: Handle (typecheck)


427-427: undefined: Handle (typecheck)


449-449: undefined: Handle (typecheck)


535-535: undefined: Handle (typecheck)


544-544: undefined: Handle (typecheck)


568-568: undefined: customVal (typecheck)


870-870: undefined: Handle (typecheck)


1416-1416: undefined: webRequestT (typecheck)


1429-1429: undefined: webRequestT (typecheck)


1453-1453: undefined: webRequestT (typecheck)


1475-1475: undefined: webRequestT (typecheck)


1499-1499: undefined: webRequestT (typecheck)


1536-1536: undefined: webRequestT (typecheck)


1558-1558: undefined: webRequestT (typecheck)


1581-1581: undefined: webRequestT (typecheck)


1605-1605: undefined: webRequestT (typecheck)


1617-1617: undefined: webRequestT (typecheck)


2135-2135: undefined: withContentType (typecheck)

Additional comments not posted (4)
gateway/gateway_test.go (4)

19-19: Added import of github.com/rudderlabs/rudder-schemas/go/stream is appropriate for handling the new payload fields.


1898-1993: The test cases in extractJobsFromInternalBatchPayload correctly handle scenarios where receivedAt and requestIP are either present or need to be added. This aligns with the PR's objective to ensure these fields are correctly managed in payloads.


Line range hint 1416-1416: The type webRequestT is undefined in the provided context. Ensure that this type is either defined or imported correctly to avoid compilation errors.


Line range hint 1416-1416: The type webRequestT is undefined in the provided context. Ensure that this type is either defined or imported correctly to avoid compilation errors.

@BonapartePC BonapartePC merged commit bc595d5 into master Jun 6, 2024
52 checks passed
@BonapartePC BonapartePC deleted the chore.setValuesInPayload branch June 6, 2024 09:18
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.

3 participants