-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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(cheatcodes
): Make serializeString
always serialize values into a string, add serializeJson
cheatcode
#4602
fix(cheatcodes
): Make serializeString
always serialize values into a string, add serializeJson
cheatcode
#4602
Conversation
9495814
to
3bde428
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gm, adding this for convo and alignment (as i'm working on parseJson stuff i can take over on this)
I think the assumption being broken here is that serializeString
has two uses:
- If the value passed in is a valid object, then it will be serialized as an object.
- If the value passed in is a string, then it will be serialized as a string.
The note on the book supports this assumption: https://book.getfoundry.sh/cheatcodes/serialize-json?highlight=serializestring#example
IMHO, this is a huge footgun actually. I believe serializeString
should explicitly, always serialize objects to string, and have some other cheatcode like serializeJson
that always expects serializable objects for composability. wdyt @mds1 ?
This seems like a good solution to me, would be curious to confirm with @sakulstra also |
cheatcodes
): Make serializeString
always serialize values into a string, add serializeJson
cheatcode
@mds1 & @mattsse updated this PR with the new scope:
|
sgtm!
Yea, given this we probably should merge this into the v1 branch and hold off on releasing it, since it might break user scripts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agree, lgtm
lgtm, agree with the gist of the discussion here. Regarding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool! i'd say let's keep this for v1, as it's a breaking change
Motivation
Closes #4601
don't rely on
from_str
when usingserializeString
this fails a test
test_serializeNotSimpleJson
that uses a serialized string a serializes it again.not sure what to make of this. wdyt @odyslam ?
I think
serialize string
was ratherserialize object
, so unsure if this change breaks some assumptions.Solution