Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion service/entityresolution/multi-strategy/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 6 additions & 2 deletions service/entityresolution/multi-strategy/service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
}
Expand Down
Loading