From 82fad1176be127876dbeeda8b69df62300c2d3ef Mon Sep 17 00:00:00 2001 From: Fred Carle Date: Fri, 24 Jan 2025 18:42:24 -0500 Subject: [PATCH] update error to be more precise --- internal/request/graphql/schema/errors.go | 2 +- .../create/embeddings/embedding_test.go | 40 ++++++++++++++++++- 2 files changed, 39 insertions(+), 3 deletions(-) diff --git a/internal/request/graphql/schema/errors.go b/internal/request/graphql/schema/errors.go index 8e3c473433..3f9f6a5de2 100644 --- a/internal/request/graphql/schema/errors.go +++ b/internal/request/graphql/schema/errors.go @@ -43,7 +43,7 @@ const ( errDirectiveWithUnknownArg string = "directive with unknown argument" errConstraintsInvalidProp string = "constraints directive with invalid property" errEmbeddingInvalidProp string = "embedding directive with invalid property" - errInvalidTypeForEmbedding string = "embedding can only be applied to array of float32 fields" + errInvalidTypeForEmbedding string = "embedding can only be applied to array of non-nillable float32 fields" ) var ( diff --git a/tests/integration/mutation/create/embeddings/embedding_test.go b/tests/integration/mutation/create/embeddings/embedding_test.go index 1c1a925ff2..3b6535c723 100644 --- a/tests/integration/mutation/create/embeddings/embedding_test.go +++ b/tests/integration/mutation/create/embeddings/embedding_test.go @@ -29,7 +29,7 @@ func TestMutationCreate_WithIntForEmbedding_ShouldError(t *testing.T) { name_v: [Int!] @embedding } `, - ExpectedError: "embedding can only be applied to array of float32 fields", + ExpectedError: "embedding can only be applied to array of non-nillable float32 fields", }, }, } @@ -47,7 +47,43 @@ func TestMutationCreate_WithFloatForEmbedding_ShouldError(t *testing.T) { name_v: [Float!] @embedding } `, - ExpectedError: "embedding can only be applied to array of float32 fields", + ExpectedError: "embedding can only be applied to array of non-nillable float32 fields", + }, + }, + } + + testUtils.ExecuteTestCase(t, test) +} + +func TestMutationCreate_WithFloat64ForEmbedding_ShouldError(t *testing.T) { + test := testUtils.TestCase{ + Description: "Create mutation with invalid type for embedding", + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: ` + type Users { + name_v: [Float64!] @embedding + } + `, + ExpectedError: "embedding can only be applied to array of non-nillable float32 fields", + }, + }, + } + + testUtils.ExecuteTestCase(t, test) +} + +func TestMutationCreate_WithNillableFloat32ForEmbedding_ShouldError(t *testing.T) { + test := testUtils.TestCase{ + Description: "Create mutation with invalid type for embedding", + Actions: []any{ + testUtils.SchemaUpdate{ + Schema: ` + type Users { + name_v: [Float32] @embedding + } + `, + ExpectedError: "embedding can only be applied to array of non-nillable float32 fields", }, }, }