Skip to content

Commit 92ac161

Browse files
committed
Fix lint error and add tests.
Signed-off-by: Revital Sur <eres@il.ibm.com>
1 parent a884a0f commit 92ac161

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

pkg/coordinator/steps/render.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ func (s *RenderStep) executeGenerate(ctx context.Context, reqCtx *pipeline.Reque
157157
return fmt.Errorf("render: features must be an object, got %T: %w", rawFeatures, pipeline.ErrBadRequest)
158158
}
159159
}
160+
entries, err := extractMultimodalEntries(features)
160161
if err != nil {
161162
return fmt.Errorf("render: %w", err)
162163
}

pkg/coordinator/steps/render_test.go

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,54 @@ func TestRenderStep_GenerateFormat_MultipleImages(t *testing.T) {
525525
}
526526
}
527527

528+
func TestRenderStep_GenerateFormat_MalformedFeatures(t *testing.T) {
529+
for _, tc := range []struct {
530+
name string
531+
features any
532+
}{
533+
{"string", "not-an-object"},
534+
{"array", []any{"a", "b"}},
535+
{"number", float64(42)},
536+
} {
537+
t.Run(tc.name, func(t *testing.T) {
538+
step, _ := NewRenderStep(nil, map[string]any{})
539+
reqCtx := &pipeline.RequestContext{
540+
OriginalPath: gateway.DefaultGeneratePath,
541+
Body: map[string]any{
542+
"model": "test-model",
543+
"token_ids": []any{float64(1), float64(2), float64(3)},
544+
"features": tc.features,
545+
},
546+
}
547+
err := step.Execute(context.Background(), reqCtx)
548+
if err == nil {
549+
t.Fatal("expected error for malformed features")
550+
}
551+
if !errors.Is(err, pipeline.ErrBadRequest) {
552+
t.Errorf("expected ErrBadRequest, got %v", err)
553+
}
554+
})
555+
}
556+
}
557+
558+
func TestRenderStep_GenerateFormat_NullFeatures(t *testing.T) {
559+
step, _ := NewRenderStep(nil, map[string]any{})
560+
reqCtx := &pipeline.RequestContext{
561+
OriginalPath: gateway.DefaultGeneratePath,
562+
Body: map[string]any{
563+
"model": "test-model",
564+
"token_ids": []any{float64(1), float64(2), float64(3)},
565+
"features": nil,
566+
},
567+
}
568+
if err := step.Execute(context.Background(), reqCtx); err != nil {
569+
t.Fatalf("unexpected error for null features: %v", err)
570+
}
571+
if len(reqCtx.MultimodalEntries) != 0 {
572+
t.Fatalf("expected no multimodal entries, got %d", len(reqCtx.MultimodalEntries))
573+
}
574+
}
575+
528576
func TestRenderStep_GenerateFormat_MissingTokenIDs(t *testing.T) {
529577
step, _ := NewRenderStep(nil, map[string]any{})
530578
reqCtx := &pipeline.RequestContext{

0 commit comments

Comments
 (0)