Repository navigation
[BI-2931] Address final areas where brapi programDbId can be used instead of BI id - #583
jloux-brapi wants to merge 5 commits into
Conversation
humsika
left a comment
There was a problem hiding this comment.
I left an inline comment about error handling in the root programs endpoint.
| for (Program program : programs) { | ||
| try { | ||
| program.setBrapiProgram(new BrAPIProgram().programDbId(programService.getBrAPIProgramDbId(program.getId()))); | ||
| } catch (ApiException e) { |
There was a problem hiding this comment.
getBrAPIProgramDbId() → getById() → ProgramDAOImpl.getProgramBrAPI() throws HttpServerException, not ApiException, when the BrAPI program is missing or the server can't be reached. This catch never runs. The exception goes to InternalServerErrorHandler and returns a generic 500. Since this endpoint now calls BrAPI for every program, one failing program fails the user's whole program list (and GET /brapi/v2/programs/{programDbId}, which calls it). Could we catch HttpServerException here, and decide whether to skip the failing program or fail the request?
There was a problem hiding this comment.
I think we can do that, but I also believe it's overkill. If we truly can't reach the server I would want requests to fail in this way, so I think a 500 is accurate.
It's unfortunate a single program could fail this, but if the server is unreachable in any case for a get I think a 500 is the appropriate response. This endpoint I believe is seldom used so risk overall is very low.
There was a problem hiding this comment.
Fair enough on a 500 being the right response here. But the new empty catch (Exception ex) at line 93 doesn't log or rethrow. It swallows the HttpServerException, brapiProgram stays null, and convertToBrAPI() (line 222) then throws an NPE. We still return a 500, but the logs only show the NPE, not the BrAPI failure.
Could we either remove the catch (so the original exception is logged and returns a 500, matching your reasoning), or log it and skip programs with a null brapiProgram? Either is fine with me; the empty catch is the only issue.
There was a problem hiding this comment.
Done, sorry, didn't mean to commit that.
| @@ -127,7 +127,6 @@ public HttpResponse<BrAPIObservationUnitListResponse> observationunitsGet(@PathV | |||
| Optional.ofNullable(studyDbId), | |||
| Optional.ofNullable(germplasmDbId)) | |||
There was a problem hiding this comment.
With the override removed, OUs now return the BrAPI germplasmDbId, but the germplasmDbId filter in BrAPIObservationUnitDAO.getObservationUnits() (line 254) still compares against the BI UUID in additionalInfo.germplasmId. Filtering by the returned ID now gives no results. The TODO there points at BI-3006, which is closed. Can we change the filter to compare ou.getGermplasmDbId() (or pass germplasmDbIds in the search request) in this PR?
Description
Story: BI-2931
BrAPITrialsControllerBrAPIObservationUnitsControllerDependencies
Testing
This will involve testing the BI-BrAPI endpoints. You will need a bearer token generated in DeltaBreed
BrAPItab to test these.programDbIdin the response is the brapi program dbId and that it corresponds to the appropriate programtrialDbIdfrom an entry in the last response to test the GET trials by dbId endpoint (/programs/{biProgramId}/brapi/v2/trials/{brapiTrialDbId} and verify theprogramDbIdin the response is the brapi programDbId and that it corresponds to the appropriate program.programDbIdin the response is the brapi program dbId and that it corresponds to the appropriate program. Verify also that thegermplasmDbIdin the response is a brapi germplasm dbId.observationUnitDbIdfrom an entry in the last response to test the GET observationunits by DbId endpoint (/programs/{biProgramId}/brapi/v2/observationunits/observationUnitDbId and verify theprogramDbIdin the response is the brapi program dbId and that it corresponds to the appropriate program. Verify also that thegermplasmDbIdin the response is a brapi germplasm dbId.programDbIdin the response is a brapi program dbId and that it corresponds to the appropriate programprogramDbIdfrom an entry in the last response to test the GET programs endpoint (/programs/{biProgramId}/brapi/v2/programs/{programDbId}) and verify theprogramDbIdin the response is a brapi program dbId and that it corresponds to the appropriate programFor the following two endpoints, for the bearer token it seems you can use one generated by any program.
programDbIdin the response is a brapi program dbId and that it corresponds to the appropriate programprogramDbIdin the response is a brapi program dbId and that it corresponds to the appropriate programChecklist: