diff --git a/apps/opik-backend/config.yml b/apps/opik-backend/config.yml index 6d5660b947..5aaa4ba2db 100644 --- a/apps/opik-backend/config.yml +++ b/apps/opik-backend/config.yml @@ -28,7 +28,7 @@ databaseAnalytics: username: ${ANALYTICS_DB_USERNAME:-opik} password: ${ANALYTICS_DB_PASS:-opik} databaseName: ${ANALYTICS_DB_DATABASE_NAME:-opik} - queryParameters: ${ANALYTICS_DB_QUERY_PARAMETERS:-health_check_interval=2000&compress=1&auto_discovery=true&failover=3} + queryParameters: ${ANALYTICS_DB_QUERY_PARAMETERS:-health_check_interval=2000&compress=1&auto_discovery=true&failover=3&custom_http_params=max_query_size=100000000} health: healthCheckUrlPaths: [ "/health-check" ] diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java index 2d5640ad40..217e0dd484 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/SpansResourceTest.java @@ -3143,6 +3143,27 @@ void createAndGetById() { getAndAssert(expectedSpan, API_KEY, TEST_WORKSPACE); } + @Test + void createAndGet__whenSpanInputIsBig__thenReturnSpan() { + + int size = 1000; + + Map jsonMap = IntStream.range(0, size) + .mapToObj(i -> Map.entry(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAscii(size))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + var expectedSpan = podamFactory.manufacturePojo(Span.class).toBuilder() + .projectId(null) + .parentSpanId(null) + .input(JsonUtils.readTree(jsonMap)) + .output(JsonUtils.readTree(jsonMap)) + .build(); + + createAndAssert(expectedSpan, API_KEY, TEST_WORKSPACE); + + getAndAssert(expectedSpan, API_KEY, TEST_WORKSPACE); + } + @Test void createOnlyRequiredFieldsAndGetById() { var expectedSpan = podamFactory.manufacturePojo(Span.class) @@ -3568,7 +3589,7 @@ void when__spanDoesNotExist__thenReturnCreateIt() { assertThat(actualEntity.metadata()).isEqualTo(spanUpdate.metadata()); assertThat(actualEntity.tags()).isEqualTo(spanUpdate.tags()); - assertThat(actualEntity.name()).isEqualTo(""); + assertThat(actualEntity.name()).isEmpty(); assertThat(actualEntity.startTime()).isEqualTo(Instant.EPOCH); assertThat(actualEntity.type()).isNull(); } diff --git a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java index 48d12ebc55..23450048d3 100644 --- a/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java +++ b/apps/opik-backend/src/test/java/com/comet/opik/api/resources/v1/priv/TracesResourceTest.java @@ -3422,6 +3422,30 @@ void create__whenProjectNameIsNull__thenAcceptAndUseDefaultProject() { assertThat(actualEntity.projectId()).isEqualTo(projectId); } + @Test + @DisplayName("when trace input is big, then accept and create trace") + void createAndGet__whenTraceInputIsBig__thenReturnSpan() { + + int size = 1000; + + Map jsonMap = IntStream.range(0, size) + .mapToObj(i -> Map.entry(RandomStringUtils.randomAlphabetic(10), RandomStringUtils.randomAscii(size))) + .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue)); + + var expectedTrace = factory.manufacturePojo(Trace.class).toBuilder() + .projectId(null) + .input(JsonUtils.readTree(jsonMap)) + .output(JsonUtils.readTree(jsonMap)) + .feedbackScores(null) + .usage(null) + .build(); + + create(expectedTrace, API_KEY, TEST_WORKSPACE); + + UUID projectId = getProjectId(expectedTrace.projectName(), TEST_WORKSPACE, API_KEY); + getAndAssert(expectedTrace, projectId, API_KEY, TEST_WORKSPACE); + } + } @Nested diff --git a/apps/opik-backend/src/test/resources/config-test.yml b/apps/opik-backend/src/test/resources/config-test.yml index 2346f9f56a..2a372b3000 100644 --- a/apps/opik-backend/src/test/resources/config-test.yml +++ b/apps/opik-backend/src/test/resources/config-test.yml @@ -26,7 +26,7 @@ databaseAnalytics: username: opik password: opik databaseName: opik - queryParameters: health_check_interval=2000&compress=1&auto_discovery=true&failover=3 + queryParameters: health_check_interval=2000&compress=1&auto_discovery=true&failover=3&custom_http_params=max_query_size=100000000 health: healthCheckUrlPaths: [ "/health-check" ]