reactivated icon indicating copy to clipboard operation
reactivated copied to clipboard

Fixes `Invariant in union serialization` when the value is a LazyObject

Open crgwbr opened this issue 1 year ago • 2 comments

crgwbr avatar Feb 02 '24 22:02 crgwbr

Seems like something we need, but I'd like to understand the use case.

How do you end up with a lazy object? Maybe our test can better reflect that, instead of direct instantiation. I don't think it needs to be a union test though, just handling of values in general. Happy to re-arrange after you let me know though.

Also remember you can run scripts/fix.sh at the root to fix formatting/style issues.

silviogutierrez avatar Feb 02 '24 22:02 silviogutierrez

Seems like something we need, but I'd like to understand the use case. How do you end up with a lazy object?

I encountered this exception due to request.csp_nonce (from django-csp) being a lazy object.

https://github.com/mozilla/django-csp/blob/main/csp/middleware.py#L32

For the test, I was just replicating the exact exception I was trying to fix. But you're right, it doesn't have to be a union test.

crgwbr avatar Feb 03 '24 01:02 crgwbr

@crgwbr sorry to intervene, do you think this could be used to pass gettext_lazy strings to templates as well?

andreighh avatar May 14 '24 15:05 andreighh

@crgwbr sorry to intervene, do you think this could be used to pass gettext_lazy strings to templates as well?

Yeah, absolutely.

crgwbr avatar May 14 '24 15:05 crgwbr

@crgwbr this is ready to go, but I need you to make an empty commit git commit --allow-empty -m "Trigger Build" so CI runs as you and the website tests are skipped.

silviogutierrez avatar May 15 '24 16:05 silviogutierrez

@silviogutierrez Done, but did it as a rebase instead to avoid the extra junk commits.

crgwbr avatar May 15 '24 16:05 crgwbr

@crgwbr : thanks, note that's not necessary because all commits on this project are squash & merge, so you'll only see a single commit in the main log.

[Cue religious war]

silviogutierrez avatar May 15 '24 16:05 silviogutierrez