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

analyzer failing to unmarshal config object #342

Closed
kyorav opened this issue Jan 24, 2024 · 6 comments · Fixed by #345
Closed

analyzer failing to unmarshal config object #342

kyorav opened this issue Jan 24, 2024 · 6 comments · Fixed by #345
Assignees

Comments

@kyorav
Copy link

kyorav commented Jan 24, 2024

The attached config object was created using the latest version of the collector (built from the main branch), invoked like this:

../../cloud-resource-collector/bin/collect -provider ibm -out tmp.json -region us-south

I ran the latest version of the analyzer (built from main branch) on an anonymized version of the result

$ ../../vpc-network-config-analyzer/bin/vpcanalyzer -vpc-config config_object.json -analysis-type all_subnets -format txt --output-file all_subnets_analysis.txt
2024/01/24 16:40:59 error parsing input vpc resources file: json: cannot unmarshal object into Go struct field Vpcdns.vpcs.dns.resolver of type vpcv1.VpcdnsResolverIntf. exiting...

config_object.json

@zivnevo
Copy link
Member

zivnevo commented Jan 24, 2024

This is expected. Analyzer only consumes official releases of the collector. You should use version 0.4.0 of the collector (there is a tag for that)

@kyorav
Copy link
Author

kyorav commented Jan 24, 2024

I ran again with v0.4.0 of the collector, and both v0.2.1 and main of the analyzer. Similar problem different messages:

2024/01/24 17:09:41 error parsing input vpc resources file: json: cannot unmarshal string into Go value of type []json.RawMessage. exiting...
2024/01/24 17:47:19 error parsing input vpc resources file: json: cannot unmarshal object into Go struct field Vpcdns.vpcs.dns.resolver of type vpcv1.VpcdnsResolverIntf. exiting...

Attaching the new config_object (collected by v0.4.0).
config_object.json

@zivnevo
Copy link
Member

zivnevo commented Jan 24, 2024

@olasaadi99 , can you please take a look? Are we missing an Unmarshal function in the collector?

@adisos
Copy link
Collaborator

adisos commented Jan 24, 2024

This seems related to another type that is now collected and has a field of type interface, thus requiring us to add in the collector yet another wrapper type (see from the error: field Vpcdns.vpcs.dns.resolver of type vpcv1.VpcdnsResolverIntf).
This should be similar to the fix that @olasaadi99 has added previously for one of the fields of routing table.

There is also an open an issue to fix/improve the unmarshaling approach (relevant issue: np-guard/cloud-resource-collector#175), so that we don't have to keep facing broken unmarshal functionality due to new collected objects with fields of type interface.

@olasaadi99
Copy link
Contributor

@adisos
Copy link
Collaborator

adisos commented Jan 28, 2024

The issue was fixed in the collector, waiting for new collector version to be released. (added specific unmarshal function for VPC of the data model).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants