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

fix asgi spec violation causing crash in lilya #2571

Closed
wants to merge 1 commit into from

Conversation

devkral
Copy link

@devkral devkral commented Feb 5, 2025

Summary

Checklist

  • I understand that this PR may be closed in case there was no previous discussion. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.

Detail:

The asgi spec only specifies that the headers are an iterable. Uvicorn assumes that the headers in scope are a list. This causes a crash at least in lilya and can cause hard to debug bugs because of exhausted iterators

Detail:

The asgi spec only specifies that the headers are an iterable. Uvicorn
assumes that the headers are a list. This causes a crash at least in
lilya and can cause hard to debug bugs
@Kludex
Copy link
Member

Kludex commented Feb 5, 2025

I don't think it assumes that.

if (1, 1) in iter([(1, 1), (2, 2), (3, 3)]):
    print('It works with iterators...')

Please post some reference to the issue.

@Kludex Kludex closed this Feb 5, 2025
@devkral
Copy link
Author

devkral commented Feb 5, 2025

it works once:

foo = iter([(1, 1), (2, 2), (3, 3)])
if (1, 1) in foo:
  print("works 1")
if (1, 1) in foo:
  print("works 2")

The problem are the iterator is exhausted. I referenced already a framework which has bugs because of this behavior.

Note: I introduced the change which caused the bug.

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.

2 participants