worker/clienterrors: add empty manifest error

If a manifest is empty we should have a specific error
code for that case and treat it as a 4xx error since
this would be bad input for a build job
This commit is contained in:
Gianluca Zuccarelli 2022-03-23 13:46:45 +00:00 committed by Sanne Raymaekers
parent 62ab822695
commit 8241e1f948
2 changed files with 5 additions and 2 deletions

View file

@ -124,12 +124,12 @@ func (impl *OSBuildKojiJobImpl) Run(job worker.Job) error {
args.Manifest = manifestJR.Manifest
if len(args.Manifest) == 0 {
err := fmt.Errorf("Received empty manifest")
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, err.Error())
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, err.Error())
return err
}
} else {
err := fmt.Errorf("Job has no manifest")
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorManifestDependency, err.Error())
result.JobError = clienterrors.WorkerClientError(clienterrors.ErrorEmptyManifest, err.Error())
return err
}
}

View file

@ -19,6 +19,7 @@ const (
ErrorKojiFinalize ClientErrorCode = 16
ErrorInvalidConfig ClientErrorCode = 17
ErrorOldResultCompatible ClientErrorCode = 18
ErrorEmptyManifest ClientErrorCode = 19
ErrorDNFDepsolveError ClientErrorCode = 20
ErrorDNFMarkingErrors ClientErrorCode = 21
@ -63,6 +64,8 @@ func GetStatusCode(err *Error) StatusCode {
return JobStatusUserInputError
case ErrorInvalidTarget:
return JobStatusUserInputError
case ErrorEmptyManifest:
return JobStatusInternalError
default:
return JobStatusInternalError
}