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

[Prioritized] Normalize line endings #2453

Open
pakrym opened this issue Dec 15, 2021 · 4 comments
Open

[Prioritized] Normalize line endings #2453

pakrym opened this issue Dec 15, 2021 · 4 comments
Assignees
Labels
Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system. Test-Proxy Anything relating to test-proxy requests or issues.

Comments

@pakrym
Copy link
Contributor

pakrym commented Dec 15, 2021

image

@JoshLove-msft @scbedd

@pakrym pakrym added the EngSys This issue is impacting the engineering system. label Dec 15, 2021
@scbedd scbedd added the Central-EngSys This issue is owned by the Engineering System team. label Feb 16, 2022
@scbedd scbedd changed the title Test proxy doesn't normalize line endings [Test-Proxy] Normalize line endings Feb 16, 2022
@scbedd scbedd added the Test-Proxy Anything relating to test-proxy requests or issues. label May 11, 2022
@scbedd scbedd changed the title [Test-Proxy] Normalize line endings [Prioritized] Normalize line endings Feb 21, 2023
@scbedd
Copy link
Member

scbedd commented Feb 21, 2023

Doing some digging into this. Found this issue which is basically exactly our scenario.

So I think we need to create a custom Utf8JsonWriter and override the WriteIndent call to insider \n instead of Environment.NewLine.

We should also update our we load the recording to ignore crlf when deserializing from the recording file.

@JoshLove-msft
Copy link
Member

JoshLove-msft commented Feb 21, 2023

Doing some digging into this. Found this issue which is basically exactly our scenario.

So I think we need to create a custom Utf8JsonWriter and override the WriteIndent call to insider \n instead of Environment.NewLine.

We should also update our we load the recording to ignore crlf when deserializing from the recording file.

I think the issue is with the actual content, not the formatted JSON. When matching we renormalize the JSON anyways so it should handle this for us. But the issue happens when someone adds line breaks based on Environment.NewLine from their own test into the request content. The workaround is to either hard-code the new line value or just remove them.

@scbedd
Copy link
Member

scbedd commented Feb 21, 2023

When matching we renormalize the JSON anyways so it should handle this for us.

Yeah I'm seeing this now.

But the issue happens when someone adds line breaks based on Environment.NewLine from their own test into the request content

Hmmm. So add a hardcoded replace on \r\n if the request content is a text content type? That's honestly the only way I see to resolve this, as the content is actually in the recorded request. It's not added to the recording when outputting the recording to disk.

when someone adds line breaks based on Environment.NewLine from their own test into the request content

I can see how this might be the proxy's place to do this, but I'm super leery towards it. Bright side is that this is not a breaking change. Existing recordings would just have crlf content silently replaced when matching.

@JoshLove-msft
Copy link
Member

Agreed that this shouldn't be a breaking change. I think essentially normalizing the line breaks when matching is the way to go.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Central-EngSys This issue is owned by the Engineering System team. EngSys This issue is impacting the engineering system. Test-Proxy Anything relating to test-proxy requests or issues.
Projects
Status: 📋 Backlog
Development

No branches or pull requests

3 participants