Skip to content

Conversation

mstoykov
Copy link
Contributor

What?

Configure the jsonv2 experimental marshal/unmarshal to work with invalid utf-8

This was missed as a thing that is needed in #4785.

This is basically what easyjson was doing before.

Due to some internal package structure I opted for a little copying over a little dependency. Mostly as the common package tests depend on tests/ws.

Why?

Apparently it is not uncommon to get invalid utf-8 from chromium and we need to not crash on it.

Checklist

  • I have performed a self-review of my code.
  • I have commented on my code, particularly in hard-to-understand areas.
  • I have added tests for my changes.
  • I have run linter and tests locally (make check) and all pass.

Checklist: Documentation (only for k6 maintainers and if relevant)

Please do not merge this PR until the following items are filled out.

  • I have added the correct milestone and labels to the PR.
  • I have updated the release notes: link
  • I have updated or added an issue to the k6-documentation: grafana/k6-docs#NUMBER if applicable
  • I have updated or added an issue to the TypeScript definitions: grafana/k6-DefinitelyTyped#NUMBER if applicable

Related PR(s)/Issue(s)

This was missed as a thing that is needed in #4785.

This is basically what easyjson was doing before.

Due to some internal package structure I opted for a little copying over
a little dependency. Mostly as the common package tests depend on
tests/ws.
@mstoykov mstoykov added this to the v1.1.0 milestone May 20, 2025
@mstoykov mstoykov requested a review from a team as a code owner May 20, 2025 08:24
@mstoykov mstoykov requested review from oleiade and codebien and removed request for a team May 20, 2025 08:24
joanlopez
joanlopez previously approved these changes May 20, 2025
//nolint:gochecknoglobals
var defaultJSONV2Options = jsonv2.JoinOptions(
jsonv2.DefaultOptionsV2(),
jsontext.AllowInvalidUTF8(true),
Copy link
Contributor

@codebien codebien May 20, 2025

Choose a reason for hiding this comment

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

Can you add a comment on it regarding why so we don't have to blame the git history, please? 🙏

@mstoykov mstoykov requested a review from joanlopez May 20, 2025 08:38
@mstoykov mstoykov merged commit 62493db into master May 20, 2025
32 checks passed
@mstoykov mstoykov deleted the cdprotoDefaultJSONOptions branch May 20, 2025 08:55
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.

3 participants