diff --git a/hydra-api.yaml b/hydra-api.yaml index df9af7ef2..727e3a24d 100644 --- a/hydra-api.yaml +++ b/hydra-api.yaml @@ -574,6 +574,24 @@ paths: schema: $ref: '#/components/schemas/JobsetEvalBuilds' + /eval/{eval-id}/errors: + get: + summary: Retrieves the evaluation error information for an evaluation identified by eval id + parameters: + - name: eval-id + in: path + description: eval identifier + required: true + schema: + type: integer + responses: + '200': + description: evaluation error details + content: + application/json: + schema: + $ref: '#/components/schemas/JobsetEvalErrors' + /jobset/{project-id}/{jobset-id}/latest-eval: get: summary: Redirects to the latest finished evaluation for a jobset @@ -951,6 +969,19 @@ components: additionalProperties: $ref: '#/components/schemas/Build' + JobsetEvalErrors: + type: object + properties: + id: + type: integer + description: The evaluation identifier + has_error: + type: boolean + description: Indicates whether this evaluation contains an error + errormsg: + type: string + description: The evaluation error message text, if an error exists + JobsetOverview: type: array items: diff --git a/subprojects/hydra/lib/Hydra/Controller/JobsetEval.pm b/subprojects/hydra/lib/Hydra/Controller/JobsetEval.pm index 77c01a840..26561b3f4 100644 --- a/subprojects/hydra/lib/Hydra/Controller/JobsetEval.pm +++ b/subprojects/hydra/lib/Hydra/Controller/JobsetEval.pm @@ -95,9 +95,24 @@ sub errors_GET { $c->stash->{template} = 'eval-error.tt'; - $c->stash->{eval} = $c->model('DB::JobsetEvals')->find($c->stash->{eval}->id, { prefetch => 'evaluationerror' }); + my $eval = $c->model('DB::JobsetEvals')->find( + $c->stash->{eval}->id, + { prefetch => 'evaluationerror' } + ); + + $c->stash->{eval} = $eval; + + my $error_obj = $eval->evaluationerror; + my $err_str = $error_obj ? $error_obj->errormsg : ''; + my $has_error = ($err_str ne '') ? \1 : \0; + + my $response = { + id => $eval->id, + has_error => $has_error, + errormsg => $err_str, + }; - $self->status_ok($c, entity => $c->stash->{eval}); + $self->status_ok($c, entity => $response); } sub create_jobset : Chained('evalChain') PathPart('create-jobset') Args(0) {