Skip to content

Fix various input normalization issues#6257

Merged
jedevc merged 2 commits into
dagger:mainfrom
jedevc:fix-mod-normalization
Dec 13, 2023
Merged

Fix various input normalization issues#6257
jedevc merged 2 commits into
dagger:mainfrom
jedevc:fix-mod-normalization

Conversation

@jedevc
Copy link
Copy Markdown
Contributor

@jedevc jedevc commented Dec 12, 2023

Fixes #6252 (the equivalent #6227, but for core types instead of user module types).

In #6167, it looks like we missed another nil check, which manifests as core module types not being set to their zero value but to an empty struct.

Additionally, it looks we regressed on #6057, and we weren't correctly converting field names back into the field names that the module requested. Thankfully, this is a pretty simple fix, and I've verified manually this works. I'm not quite sure of a test that can make this break neatly, since it didn't really (encoding/json "prefer[s] an exact match but also accept[s] a case-insensitive match").

Not doing this meant that we could accidentally return an empty struct
instead of the zero value to module clients.

This is similar in style to a previous fix that did this for user module
types.

Signed-off-by: Justin Chadwell <me@jedevc.com>
Without this, we were returning the normalized name back to the SDK -
this only seemed to work because we were being case-insensitive in
unmarshalling.

We should make sure that modules receive their inputs exactly as they
requested them.

Signed-off-by: Justin Chadwell <me@jedevc.com>
@jedevc jedevc requested a review from sipsma December 12, 2023 11:26
@jedevc jedevc added the zenith label Dec 12, 2023
Copy link
Copy Markdown
Contributor

@sipsma sipsma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great finds on all accounts, LGTM!

I'm not quite sure of a test that can make this break neatly

I think you could probably call the dag.CurrentFunctionCall() in the actual function implementation itself to get all the raw values provided to the SDK. If that does work and is easy to write a test with then I'd say go for it, but up to you, not worth blocking on.

@jedevc jedevc merged commit 3b82755 into dagger:main Dec 13, 2023
@jedevc jedevc deleted the fix-mod-normalization branch December 13, 2023 11:16
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.

🐞 Module constructor returns pointer for empty object instead of returning nil for *Directory type

2 participants