{"record":{"id":"df70dfe144e13389","repo":"goharbor/harbor","slug":"empty-json-data-to-parse","errorCode":null,"errorMessage":"empty json data to parse","messagePattern":"empty json data to parse","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/pkg/scan/export/model.go","lineNumber":69,"sourceCode":"\tCVEIds string\n\n\t// A list of one or more labels for which to export the scan data, defaults to all if empty\n\tLabels []int64\n\n\t// A list of one or more projects for which to export the scan data, defaults to all if empty\n\tProjects []int64\n\n\t// A list of repositories for which to export the scan data, defaults to all if empty\n\tRepositories string\n\n\t// A list of tags for which to export the scan data, defaults to all if empty\n\tTags string\n}\n\n// FromJSON parses robot from json data\nfunc (c *Request) FromJSON(jsonData string) error {\n\tif len(jsonData) == 0 {\n\t\treturn errors.New(\"empty json data to parse\")\n\t}\n\n\treturn json.Unmarshal([]byte(jsonData), c)\n}\n\n// ToJSON marshals Robot to JSON data\nfunc (c *Request) ToJSON() (string, error) {\n\tdata, err := json.Marshal(c)\n\tif err != nil {\n\t\treturn \"\", err\n\t}\n\n\treturn string(data), nil\n}\n\n// Execution provides details about the running status of a scan data export job\ntype Execution struct {\n\t// ID of the execution","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/goharbor/harbor/blob/7b2fd08cc568955cca339afeefab27372840d936/src/pkg/scan/export/model.go#L51-L87","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\nvar req export.Request\nerr := req.FromJSON(\"\")\n\n// after\njsonData := params[JobParamRequest].(string)\nif len(jsonData) == 0 {\n    return errors.New(\"export request payload is required\")\n}\nerr := req.FromJSON(jsonData)","handlingStrategy":"validation","validationCode":"if len(jsonData) == 0 {\n    return errors.New(\"export request JSON payload is required\")\n}\nvar req export.Request\nif err := req.FromJSON(jsonData); err != nil {\n    return err\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["scan","export","json","job-parameters"],"backgroundTag":null,"analyzedSha":"7b2fd08cc568955cca339afeefab27372840d936","analyzedAt":"2026-08-16T00:00:10.961Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}