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

Writing SPDX fails when a package has an originator object with an empty string as the originator #245

Closed
LaurentGoderre opened this issue Jun 13, 2024 · 0 comments · Fixed by #246

Comments

@LaurentGoderre
Copy link
Contributor

Minimal reproducer

package main

import (
	"bytes"
	"fmt"

	spdx_json "github.com/spdx/tools-golang/json"
	"github.com/spdx/tools-golang/spdx"
	"github.com/spdx/tools-golang/spdx/v2/common"
	"github.com/spdx/tools-golang/spdx/v2/v2_3"
)

func main() {
	w := bytes.NewBuffer(nil)
	o := common.Originator{
		OriginatorType: "type",
	}
	p := v2_3.Package{
		PackageOriginator: &o,
	}
	s := spdx.Document{
		Packages: []*v2_3.Package{
			&p,
		},
	}
	err := spdx_json.Write(s, w)
	if err != nil {
		fmt.Printf("%s", err)
	}

	fmt.Printf("%s", w.Bytes())
}

Output:

json: error calling MarshalJSON for type *common.Originator: unexpected end of JSON input
LaurentGoderre added a commit to LaurentGoderre/tools-golang that referenced this issue Jun 13, 2024
LaurentGoderre added a commit to LaurentGoderre/tools-golang that referenced this issue Jun 13, 2024
Fixes spdx#245

Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
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 a pull request may close this issue.

1 participant