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

Add fallback decoding for asgi headers #2837

Merged
merged 12 commits into from
Sep 25, 2024

Conversation

rocky-ken
Copy link
Contributor

@rocky-ken rocky-ken commented Aug 28, 2024

Description

Add fallback decoding for asgi headers if utf-8 decoding throws an error.

Duplicate of PR 1713 to hopefully get it over the finish line

Fixes #1814
Fixes #1478

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test it in asgi

Does This PR Require a Core Repo Change?

  • No.

Checklist:

See contributing.md for styleguide, changelog guidelines, and more.

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

Copy link

linux-foundation-easycla bot commented Aug 28, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

@rocky-ken rocky-ken changed the title [WIP] Add latin-1 fallback decoding for asgi headers Add latin-1 fallback decoding for asgi headers Aug 29, 2024
@rocky-ken rocky-ken marked this pull request as ready for review August 29, 2024 22:29
Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

Question: why do we want a fallback strategy to latin-1 for a wrong encoded value?

@xrmx
Copy link
Contributor

xrmx commented Aug 30, 2024

Question: why do we want a fallback strategy to latin-1 for a wrong encoded value?

And if we want it we also want tests

@xrmx
Copy link
Contributor

xrmx commented Aug 30, 2024

ASGI docs kinda suggests these should be ASCII but that's not mandatory so being less picky may be a good idea:

headers: These are byte strings of the exact byte sequences sent by the client/to be sent by the server. While modern HTTP standards say that headers should be ASCII, older ones did not and allowed a wider range of characters. Frameworks/applications should decode headers as they deem appropriate.

https://asgi.readthedocs.io/en/latest/specs/www.html#wsgi-encoding-differences

@rocky-ken
Copy link
Contributor Author

Question: why do we want a fallback strategy to latin-1 for a wrong encoded value?

Was following the previous PR and discussion here. Would a different approach be better? (Ex: try-catch the decode and pass-through)

@rocky-ken rocky-ken changed the title Add latin-1 fallback decoding for asgi headers Add fallback decoding for asgi headers Sep 5, 2024
@xrmx
Copy link
Contributor

xrmx commented Sep 6, 2024

@rocky-ken we need some tests for this to get in

@rocky-ken rocky-ken requested a review from a team September 11, 2024 21:31
@rocky-ken rocky-ken requested a review from emdneto September 17, 2024 16:33
Copy link
Member

@emdneto emdneto left a comment

Choose a reason for hiding this comment

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

Current tests don't cover the changes in ASGIGetter, right? I think would be nice to have tests for ASGIGetter too.

CHANGELOG.md Outdated Show resolved Hide resolved
@rocky-ken
Copy link
Contributor Author

Current tests don't cover the changes in ASGIGetter, right? I think would be nice to have tests for ASGIGetter too.

Not familiar with the ASGIGetter tests but I added some stuff so let me know if that covers it or not

@rocky-ken rocky-ken requested a review from emdneto September 18, 2024 18:12
@emdneto
Copy link
Member

emdneto commented Sep 18, 2024

Not familiar with the ASGIGetter tests but I added some stuff so let me know if that covers it or not

@rocky-ken they are under test_getter.py

@rocky-ken rocky-ken requested a review from a team as a code owner September 18, 2024 20:01
@rocky-ken rocky-ken requested a review from Ronald-TR September 19, 2024 15:59
@xrmx xrmx merged commit a084c2c into open-telemetry:main Sep 25, 2024
528 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants