Preserve native validation failure details
This commit is contained in:
@@ -201,6 +201,26 @@ func TestNativeProducerDoesNotInterpretFailedNativeValidation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestNativeProducerReportsCompletedValidationFailure(t *testing.T) {
|
||||
engine := nativeProducerEngine(t, producerClientFunc(func(context.Context, promptkit.GenerateRequest) (*promptkit.GenerateResponse, error) {
|
||||
return &promptkit.GenerateResponse{Content: "not JSON"}, nil
|
||||
}))
|
||||
interpreted := false
|
||||
operation := contracts.ProducerOperation[int]{Controls: contracts.ProducerControls{Mode: contracts.ModeStrict}, Assess: rejectedProducerAssessment}
|
||||
_, _, err := RunProducer(context.Background(), engine, operation, nativeProducerInitial(),
|
||||
func(context.Context, *promptkit.RunResult) (*int, []string, error) {
|
||||
interpreted = true
|
||||
return nil, nil, nil
|
||||
}, nil, nil)
|
||||
var invalid *NativeValidationError
|
||||
if !errors.As(err, &invalid) || errors.Is(err, promptkit.ErrValidation) || len(invalid.Validation.Errors) == 0 || interpreted {
|
||||
t.Fatalf("completed validation failure = %v, interpreted = %t", err, interpreted)
|
||||
}
|
||||
if !strings.Contains(err.Error(), invalid.Validation.Errors[0]) {
|
||||
t.Fatalf("native validation detail lost: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestNativeProducerFailureDoesNotRecoverEarlierCandidate(t *testing.T) {
|
||||
failure := errors.New("provider unavailable")
|
||||
for _, failCorrection := range []bool{false, true} {
|
||||
|
||||
Reference in New Issue
Block a user