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

feat: utf8 sanitizer #485

Merged

Conversation

fracasula
Copy link
Collaborator

@fracasula fracasula commented May 28, 2024

Description

This is needed by the IngestionSvc so that we don't propagate messages with invalid UTF-8 sequences to Pulsar.

If we do propagate them, then the SrcRouter won't be able to push those messages to RudderServer, because then the RudderServer gateway would fail with an error similar to the following:

pq: invalid byte sequence for encoding "UTF8": 0xd4 0x6d

Linear Ticket

< Linear_Link >

Security

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

@fracasula fracasula marked this pull request as ready for review May 28, 2024 08:59
Copy link

codecov bot commented May 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 30.60%. Comparing base (bc95a3f) to head (f91980c).
Report is 10 commits behind head on main.

Current head f91980c differs from pull request most recent head d0689e5

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

Additional details and impacted files
@@             Coverage Diff             @@
##             main     #485       +/-   ##
===========================================
- Coverage   78.98%   30.60%   -48.38%     
===========================================
  Files          90       44       -46     
  Lines        6747     3486     -3261     
===========================================
- Hits         5329     1067     -4262     
- Misses       1153     2303     +1150     
+ Partials      265      116      -149     

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

utf8/sanitize.go Outdated Show resolved Hide resolved
@lvrach
Copy link
Member

lvrach commented May 28, 2024

I believe that both functions can be replaced with standard library ones:

https://pkg.go.dev/bytes#ToValidUTF8

and

utf8.Valid

@fracasula
Copy link
Collaborator Author

I believe that both functions can be replaced with standard library ones:

https://pkg.go.dev/bytes#ToValidUTF8

and

utf8.Valid

@lvrach I'm happy to replace Invalid with utf8.Valid but I think we should consider keeping our own sanitizer because it does zero allocations while bytes.ToValidUTF8 uses append.

Given the effort spent on the IngestionSvc with all the memory optimizations, I think it makes sense to consider it. Wdyt?

@fracasula
Copy link
Collaborator Author

@lvrach I copied the exact same test cases that they have for bytes.ToValidUTF8 and I've added them to our test scenarios.

utf8/sanitize.go Outdated Show resolved Hide resolved
@fracasula fracasula enabled auto-merge (squash) May 28, 2024 16:00
@fracasula fracasula disabled auto-merge May 28, 2024 16:06
@fracasula fracasula added the DO NOT MERGE Approved but need to check more label May 28, 2024
Sidddddarth and others added 2 commits May 29, 2024 10:54
Co-authored-by: Akash Chetty <achetty.iitr@gmail.com>
Co-authored-by: Leonidas Vrachnis <leo.al.vra@gmail.com>
@fracasula fracasula force-pushed the feature/pipe-1131-fix-invalid-utf8-bytes-issue-on-ingestionsvc branch from 3555fd9 to 24ccf80 Compare May 29, 2024 09:05
@fracasula fracasula removed the DO NOT MERGE Approved but need to check more label May 29, 2024
@fracasula fracasula enabled auto-merge (squash) May 29, 2024 09:06
@fracasula fracasula merged commit 0ccb5aa into main May 29, 2024
10 checks passed
@fracasula fracasula deleted the feature/pipe-1131-fix-invalid-utf8-bytes-issue-on-ingestionsvc branch May 29, 2024 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants