asgiref icon indicating copy to clipboard operation
asgiref copied to clipboard

Should frameworks change scope values?

Open pgjones opened this issue 1 year ago • 4 comments

See https://github.com/pgjones/hypercorn/issues/75 where Starlette changes the scope["path"], should ASGI frameworks do this or consider the existing values immutable? (I don't think the specification says - I may work around by passing a copy to the framework)

pgjones avatar Sep 04 '22 16:09 pgjones

Maybe relevant: https://github.com/encode/starlette/issues/1336.

Kludex avatar Sep 04 '22 16:09 Kludex

Yeah, you're not really meant to change the value of path, I feel - since it's meant to always have root_path at the start. I'm not going to go all out and say something absolutely shouldn't, but I think if it's modified then root_path has to be included in that to make things make sense.

andrewgodwin avatar Sep 04 '22 17:09 andrewgodwin

We'll fix Starlette. It's not Hypercorn's fault. Uvicorn has the same behavior as Hypercorn. :pray:

Kludex avatar Sep 11 '22 13:09 Kludex

Related: Starlette at least mutates scope even when the spec clearly states "when middleware is modifying the scope, it should make a copy of the scope object before mutating it and passing it to the inner application" 🤷🏻‍♂️

adriangb avatar Nov 09 '22 06:11 adriangb