diff --git a/service/entityresolution/multi-strategy/service.go b/service/entityresolution/multi-strategy/service.go index 1a37f32154..0cd91048f2 100644 --- a/service/entityresolution/multi-strategy/service.go +++ b/service/entityresolution/multi-strategy/service.go @@ -116,7 +116,17 @@ func (s *Service) ResolveEntity(ctx context.Context, entityID string, claimsMap result.Metadata["strategy_provider"] = strategy.Provider result.Metadata["entity_type"] = strategy.EntityType result.Metadata["failure_strategy"] = failureStrategy - result.Metadata["attempted_strategies"] = attemptedStrategies + // Coerce []string -> []interface{} so structpb.NewValue (called by + // the v2 ResolveEntities handler when it serializes metadata into + // EntityRepresentation.AdditionalProps) can encode it. structpb's + // NewValue accepts string|float64|bool|nil|map|[]interface{} only - + // a raw []string trips "proto: invalid type: []string" and the + // resolved entity is silently dropped via `continue` in the loop. + attemptedAny := make([]interface{}, len(attemptedStrategies)) + for i, strat := range attemptedStrategies { + attemptedAny[i] = strat + } + result.Metadata["attempted_strategies"] = attemptedAny return result, nil } diff --git a/service/entityresolution/multi-strategy/service_test.go b/service/entityresolution/multi-strategy/service_test.go index d767db1bc2..130bb7da0b 100644 --- a/service/entityresolution/multi-strategy/service_test.go +++ b/service/entityresolution/multi-strategy/service_test.go @@ -296,8 +296,12 @@ func TestMultiStrategyService_FailureStrategyContinue(t *testing.T) { t.Errorf("Expected entity_type '%s', got '%v'", types.EntityTypeSubject, result.Metadata["entity_type"]) } - // Verify attempted strategies metadata - attemptedStrategies, ok := result.Metadata["attempted_strategies"].([]string) + // Verify attempted strategies metadata. Stored as []interface{} (rather + // than []string) so the value can flow through structpb.NewValue when + // the v2 ResolveEntities handler serializes result.Metadata into + // EntityRepresentation.AdditionalProps; structpb does not accept + // []string. + attemptedStrategies, ok := result.Metadata["attempted_strategies"].([]interface{}) if !ok || len(attemptedStrategies) != 2 { t.Errorf("Expected attempted_strategies to contain 2 strategies, got %v", result.Metadata["attempted_strategies"]) }