Conversation
bc5e29e to
3d60bca
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to fix the /eval/<id>/errors REST endpoint so that JSON responses include the evaluation error message (errormsg) that was previously omitted due to lazy-loading/serialization behavior around the EvaluationErrors relation.
Changes:
- Refetches
JobsetEvalwithevaluationerrorprefetched for the/eval/<id>/errorsendpoint. - Builds a plain hash response containing
id, a newhas_errorboolean, anderrormsgfor JSON serialization.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| my $has_error = ($err_str ne '') ? \1 : \0; | ||
|
|
||
| my $response = { | ||
| id => $eval->id, | ||
| has_error => $has_error, | ||
| errormsg => $err_str, | ||
| }; |
There was a problem hiding this comment.
I'm not doing $has_error any more. And having real booleans in the JSON makes sense.
| my $response = { | ||
| id => $eval->id, | ||
| has_error => $has_error, | ||
| errormsg => $err_str, | ||
| }; |
There was a problem hiding this comment.
Previously, the JSON API of this endpoint was not specified at all in the OpenAPI schema. (Of course, this does not mean it wasn't relied upon, though it's unlikely given that it did exactly the same thing as the normal JobsetEval endpoint without /errors). I've added OpenAPI docs now.
| my $eval = $c->model('DB::JobsetEvals')->find( | ||
| $c->stash->{eval}->id, | ||
| { prefetch => 'evaluationerror' } | ||
| ); | ||
|
|
||
| $c->stash->{eval} = $eval; | ||
|
|
||
| my $error_obj = $eval->evaluationerror; |
There was a problem hiding this comment.
This works as well, at least if you re-add
$c->stash->{eval} = $c->model('DB::JobsetEvals')->find(
$c->stash->{eval}->id,
{ prefetch => 'evaluationerror' }
);But I would like to see a human opinion on this matter. I don't know enough Perl to trust a clanker with it.
| my $err_str = $error_obj ? $error_obj->errormsg : ''; | ||
| my $has_error = ($err_str ne '') ? \1 : \0; |
There was a problem hiding this comment.
Nope:
DBIx::Class::Row::get_column(): No such column 'has_error' on Hydra::Model::DB::EvaluationErrors at /home/kfm/src/hydra/subprojects/hydra/script/../lib/Hydra/Controller/JobsetEval.pm line 107
0653b77 to
5f87c31
Compare
There was a problem hiding this comment.
Pull request overview
This PR addresses missing evaluation error text in the /eval/<id>/errors REST endpoint when requesting JSON by returning a plain hash payload instead of a raw DBIx object (which dropped joined relation data during serialization). It also documents the endpoint in the OpenAPI spec.
Changes:
- Update
/eval/<id>/errorscontroller logic to build an explicit JSON entity containingid,has_error, anderrormsg. - Add OpenAPI path + schema for
/eval/{eval-id}/errors. - Minor OpenAPI formatting/example adjustments.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| subprojects/hydra/lib/Hydra/Controller/JobsetEval.pm | Builds an explicit response entity for /eval/<id>/errors instead of serializing the DBIx row directly. |
| hydra-api.yaml | Documents the new /eval/{eval-id}/errors endpoint and adds a JobsetEvalErrors schema. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
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.
5f87c31 to
35f301d
Compare
Description
When querying the
/eval/<id>/errorsendpoint via the REST API (Accept: application/json), the response previously returned the standardJobsetEvalmetadata but completely omitted the actual evaluation error message.Root cause:
Due to previous database optimizations,
errormsgis lazy-loaded and stored in theEvaluationErrorsrelation. While theeval-error.ttHTML template correctly traversed the prefetchedevaluationerrorobject, passing the raw DBIx object to Catalyst's$self->status_ok()caused the JSON serializer to drop the joined table data entirely.Solution:
This explicitly extracts the
evaluationerrordata into a plain hash before passing it tostatus_ok. It also introduces a cleanhas_errorboolean to make it easier for API consumers to check for failures.Example Output
Testing with
curl -H "Accept: application/json" http://localhost:3000/eval/<id>/errors | jq .When an error exists:
{ "id": 2, "has_error": true, "errormsg": "in job ‘x86_64-linux.broken’:\nerror:\n … while calling the 'throw' builtin..." }When no error exists:
{ "id": 2, "has_error": false, "errormsg": "" }