goharbor/harbor · error
empty json data to parse
Error message
empty json data to parse
What it means
Returned by scan-export Request.FromJSON when the input string is empty. The export request model (harbor repositories, tags, CVE ids, projects lists) is deserialized from a JSON string carried in job parameters; an empty payload is rejected before json.Unmarshal.
Source
Thrown at src/pkg/scan/export/model.go:69
CVEIds string
// A list of one or more labels for which to export the scan data, defaults to all if empty
Labels []int64
// A list of one or more projects for which to export the scan data, defaults to all if empty
Projects []int64
// A list of repositories for which to export the scan data, defaults to all if empty
Repositories string
// A list of tags for which to export the scan data, defaults to all if empty
Tags string
}
// FromJSON parses robot from json data
func (c *Request) FromJSON(jsonData string) error {
if len(jsonData) == 0 {
return errors.New("empty json data to parse")
}
return json.Unmarshal([]byte(jsonData), c)
}
// ToJSON marshals Robot to JSON data
func (c *Request) ToJSON() (string, error) {
data, err := json.Marshal(c)
if err != nil {
return "", err
}
return string(data), nil
}
// Execution provides details about the running status of a scan data export job
type Execution struct {
// ID of the executionView on GitHub (pinned to 7b2fd08cc5)
Solutions
- Ensure the export job parameters contain the serialized request JSON before submitting the job
- Validate len(params) payload at the API boundary and reject with BAD_REQUEST there
- Re-create the export request via the UI/API if the job was corrupted
Example fix
// before
var req export.Request
err := req.FromJSON("")
// after
jsonData := params[JobParamRequest].(string)
if len(jsonData) == 0 {
return errors.New("export request payload is required")
}
err := req.FromJSON(jsonData) Defensive patterns
Strategy: validation
Validate before calling
if len(jsonData) == 0 {
return errors.New("export request JSON payload is required")
}
var req export.Request
if err := req.FromJSON(jsonData); err != nil {
return err
} Prevention
- Validate the request payload is non-empty at the API boundary
- Include the serialized request in job parameters every time you enqueue an export
- Unit-test the enqueue path with the exact parameters map you ship
When it happens
Trigger: Launching an export scan-data job whose job parameters omit the request JSON; passing an empty string from the API layer to the job; job parameters truncated during job re-enqueue.
Common situations: API clients posting the export request body as empty; job service replaying old jobs with missing params; integration code building job.Parameters map without the request key.
Related errors
- Internal dir for tls {} not exist
- Trace enabled but no trace exporter set
- empty JSON data
- File {} not exist
- invalid {}
AI-assisted analysis of goharbor/harbor@7b2fd08cc5 (2026-08-16).
Data as JSON: /api/errors/df70dfe144e13389.
Report an issue: GitHub.