Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[OPIK-487] Fix null pointer #752

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,8 @@ private List<Span> bindSpanToProjectAndId(SpanBatch batch, List<Project> project

public Mono<ProjectStats> getStats(@NonNull SpanSearchCriteria criteria) {
if (criteria.projectId() != null) {
return spanDAO.getStats(criteria);
return spanDAO.getStats(criteria)
.switchIfEmpty(Mono.just(ProjectStats.empty()));
}

return makeMonoContextAware(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ public Mono<BiInformationResponse> getTraceBIInformation() {
public Mono<ProjectStats> getStats(@NonNull TraceSearchCriteria criteria) {

if (criteria.projectId() != null) {
return dao.getStats(criteria);
return dao.getStats(criteria)
.switchIfEmpty(Mono.just(ProjectStats.empty()));
}

return getProjectByName(criteria.projectName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4847,6 +4847,15 @@ void feedback__whenFeedbackSpanBatchHasMaxSize__thenReturnNoContentAndCreateScor
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class GetSpanStats {

@Test
@DisplayName("when project id does not exist, then return empty list")
void getSpanStats__whenProjectIdDoesNotExist__thenReturnEmptyList() {

UUID projectId = generator.generate();

getStatsAndAssert(null, projectId, null, null, null, API_KEY, TEST_WORKSPACE, List.of());
}

@Test
void findWithUsage() {
var projectName = RandomStringUtils.randomAlphanumeric(10);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4947,6 +4947,15 @@ void feedback__whenFeedbackTraceIdIsNotValid__thenReturn400() {
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
class GetTraceStats {

@Test
@DisplayName("when project id does not exist, then return empty list")
void getTraceStats__whenProjectIdDoesNotExist__thenReturnEmptyList() {

UUID projectId = generator.generate();

getStatsAndAssert(null, projectId, null, API_KEY, TEST_WORKSPACE, List.of());
}

@Test
@DisplayName("when project name and project id are null, then return bad request")
void getTraceStats__whenProjectNameAndIdAreNull__thenReturnBadRequest() {
Expand Down