goharbor/harbor · error

empty JSON data

Error message

empty JSON data

What it means

Error "empty JSON data" thrown in goharbor/harbor.

Source

Thrown at src/pkg/scan/report/supported_mimes.go:43

// SupportedMimes indicates what mime types are supported to render at UI end.
var SupportedMimes = map[string]any{
	// The native report type
	v1.MimeTypeNativeReport:               (*vuln.Report)(nil),
	v1.MimeTypeGenericVulnerabilityReport: (*vuln.Report)(nil),
}

// ResolveData is a helper func to parse the JSON data with the given mime type.
func ResolveData(mime string, jsonData []byte, options ...Option) (any, error) {
	// If no resolver defined for the given mime types, directly ignore it.
	// The raw data will be used.
	t, ok := SupportedMimes[mime]
	if !ok {
		return nil, nil
	}

	if len(jsonData) == 0 {
		return nil, errors.New("empty JSON data")
	}

	ty := reflect.TypeOf(t)
	if ty.Kind() == reflect.Ptr {
		ty = ty.Elem()
	}

	// New one
	rp := reflect.New(ty).Elem().Addr().Interface()

	if err := json.Unmarshal(jsonData, rp); err != nil {
		return nil, err
	}

	ops := &Options{}
	for _, op := range options {
		op(ops)
	}

View on GitHub (pinned to 7b2fd08cc5)

When it happens

Trigger: Thrown at src/pkg/scan/report/supported_mimes.go:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16). Data as JSON: /api/errors/bbfd888ccfa3b354. Report an issue: GitHub.