From 35f301d2ebd34a41087cb4f073835b1c554a609d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kier=C3=A1n=20Meinhardt?= Date: Wed, 18 Mar 2026 16:37:40 +0100 Subject: [PATCH] hydra: explicitly return errormsg for eval errors endpoint Previously, returning the DBIx object directly to status_ok caused the JSON serializer to ignore the joined evaluationerror table. This explicitly maps the required fields into a hash to ensure errormsg and has_error are exposed to REST clients. --- hydra-api.yaml | 31 +++++++++++++++++++ .../hydra/lib/Hydra/Controller/JobsetEval.pm | 19 ++++++++++-- 2 files changed, 48 insertions(+), 2 deletions(-) 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) {