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 serialization of LazyObject #320

Merged
merged 1 commit into from
May 15, 2024

Conversation

crgwbr
Copy link
Contributor

@crgwbr crgwbr commented Feb 2, 2024

No description provided.

@silviogutierrez
Copy link
Owner

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.

@crgwbr
Copy link
Contributor Author

crgwbr commented Feb 3, 2024

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.

@andreighh
Copy link

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

@crgwbr
Copy link
Contributor Author

crgwbr commented May 14, 2024

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

Yeah, absolutely.

@silviogutierrez
Copy link
Owner

@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.

@crgwbr
Copy link
Contributor Author

crgwbr commented May 15, 2024

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

@silviogutierrez
Copy link
Owner

@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 silviogutierrez changed the title Fixes Invariant in union serialization when the value is a LazyObject Fix serialization of LazyObject May 15, 2024
@kodiakhq kodiakhq bot merged commit f74c553 into silviogutierrez:main May 15, 2024
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants