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

Action-FuncRef-Invoke is not unmarshaling into InvokeType #179

Closed
ilewin opened this issue Aug 4, 2023 · 3 comments
Closed

Action-FuncRef-Invoke is not unmarshaling into InvokeType #179

ilewin opened this issue Aug 4, 2023 · 3 comments
Labels
bug 🐛 Something isn't working

Comments

@ilewin
Copy link
Contributor

ilewin commented Aug 4, 2023

Although Action.FunctionRef.Invoke field is set in the JSON while unmarshaling into a struct the field is not set. Seems due to the fact that its of InvokeType.

Expect to unmarshal correclty

set invoke in FuncRef Action and try to unmarshal into a struct

func (f *FunctionRef) UnmarshalJSON(data []byte) error {
	funcRef := make(map[string]interface{})
	if err := json.Unmarshal(data, &funcRef); err != nil {
		f.RefName, err = unmarshalString(data)
		if err != nil {
			return err
		}
		return nil
	}

	f.RefName = requiresNotNilOrEmpty(funcRef["refName"])
	if _, found := funcRef["arguments"]; found {
		f.Arguments = funcRef["arguments"].(map[string]interface{})
	}
	f.SelectionSet = requiresNotNilOrEmpty(funcRef["selectionSet"])

	// Missing part ?
       if _, found := funcRef["invoke"]; found {
		if invoke, ok := funcRef["invoke"].(string); ok {
			f.Invoke = InvokeType(invoke)
		}
	}
       // End of  Missing part
	return nil
}
@ilewin ilewin added the bug 🐛 Something isn't working label Aug 4, 2023
@ricardozanini
Copy link
Member

@ilewin thanks for reporting it. Can you open a PR to fix it? I think it's rather simple.

@spolti
Copy link
Member

spolti commented Aug 25, 2023

Seems that it is fixed already, added a small check to make sure it is unmarshalled: #184

@ricardozanini
Copy link
Member

Seems that it is fixed already, added a small check to make sure it is unmarshalled: #184

Approved!

@spolti spolti closed this as completed Aug 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants