Skip to content

Update json object parsing

What does this MR do and why?

Exported json objects do not have optional attributes set if they are empty httcps://gitlab.com/gitlab-org/security-products/license-db/license-exporter/-/merge_requests/33/diffs#b6d3b1fd077dc0155d82faea974b568520447981_0_32:

type CompressedLicenseGroup struct {
	// Name is the package name.
	Name string `json:"name"`

	// LowestVersion is the lowest parsable version for which licenses are known.
	LowestVersion string `json:"lowest_version,omitempty"`

	// HighestVersion is the highest parsable version for which licenses are known.
	HighestVersion string `json:"highest_version,omitempty"`

	// DefaultLicenses are the SPDX identifiers of the licenses that apply
	// to versions not listed in OtherLicenses.
	DefaultLicenses []string `json:"default_licenses"`

	// OtherLicenses gives the SPDX identifiers of versions
	// that don't have the DefaultLicenses.
	OtherLicenses []LicenseSet `json:"other_licenses,omitempty"`
}

This MR updates CompressedPackageDataObject to not error when optional attributes are not set.

How to set up and validate locally

Run the spec but revert the changes made to CompressedPackageDataObject in this MR.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #408901 (closed)

Merge request reports