Skip to content

Commit

Permalink
update error to be more precise
Browse files Browse the repository at this point in the history
  • Loading branch information
fredcarle committed Jan 25, 2025
1 parent 44ccc1c commit 82fad11
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/request/graphql/schema/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
40 changes: 38 additions & 2 deletions tests/integration/mutation/create/embeddings/embedding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
}
Expand All @@ -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",
},
},
}
Expand Down

0 comments on commit 82fad11

Please sign in to comment.