From 9da9eb77e508278fd6466dcd30a2434b32318f39 Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Fri, 8 May 2026 10:56:41 -0700 Subject: [PATCH] fix dynamic builder runtime mapping for option responses Allow builder-native response kinds like OPTION to resolve to DYNAMIC so schema-driven definition creation succeeds. Co-authored-by: Cursor --- internal/domain/question_type_builder.go | 9 +++++++++ internal/domain/question_type_builder_test.go | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/internal/domain/question_type_builder.go b/internal/domain/question_type_builder.go index 13d1594..fd95582 100644 --- a/internal/domain/question_type_builder.go +++ b/internal/domain/question_type_builder.go @@ -221,7 +221,11 @@ func ResolveRuntimeQuestionTypeFromDefinition(key string, responseKinds []string return "TRUE_FALSE" } + hasNonAuxiliary := false for _, kind := range normalizeKindList(responseKinds) { + if _, aux := responseKindsAuxiliary[kind]; !aux { + hasNonAuxiliary = true + } switch kind { case string(ResponseAudioResponse): return "AUDIO" @@ -237,6 +241,11 @@ func ResolveRuntimeQuestionTypeFromDefinition(key string, responseKinds []string } } + // Builder-native response kinds should still be persistable/executable as DYNAMIC. + if hasNonAuxiliary { + return "DYNAMIC" + } + return "" } diff --git a/internal/domain/question_type_builder_test.go b/internal/domain/question_type_builder_test.go index 1d3e45d..c105433 100644 --- a/internal/domain/question_type_builder_test.go +++ b/internal/domain/question_type_builder_test.go @@ -86,6 +86,13 @@ func TestResolveRuntimeQuestionTypeFromDefinition_skipsAuxiliaryKinds(t *testing } } +func TestResolveRuntimeQuestionTypeFromDefinition_builderNativeKinds(t *testing.T) { + got := ResolveRuntimeQuestionTypeFromDefinition("dynamic_builder", []string{"OPTION", "ANSWER_TIMER"}) + if got != "DYNAMIC" { + t.Fatalf("expected DYNAMIC, got %q", got) + } +} + func TestValidatePersistableQuestionTypeDefinition_unmappable(t *testing.T) { err := ValidatePersistableQuestionTypeDefinition("custom", []string{"ANSWER_TIMER"}) if err == nil || !strings.Contains(err.Error(), "unable to map definition") {