Skip to content

fix(attestation): fix deduplication of policy evaluations#3016

Open
jiparis wants to merge 2 commits intochainloop-dev:mainfrom
jiparis:jiparis/fix-dedup-policy-eval
Open

fix(attestation): fix deduplication of policy evaluations#3016
jiparis wants to merge 2 commits intochainloop-dev:mainfrom
jiparis:jiparis/fix-dedup-policy-eval

Conversation

@jiparis
Copy link
Copy Markdown
Member

@jiparis jiparis commented Apr 9, 2026

Summary

  • Replace reflect.DeepEqual with maps.Equal for policy evaluation deduplication so that nil and empty maps are treated as equivalent
  • Extract policyEvalMatches helper to encapsulate the comparison logic used at both dedup sites
  • Add table-driven tests covering nil vs empty map, matching args, and differing policies

Context

All trace attestations evaluate policies twice (init + push phases). After protojson round-trip serialization, the With field changes from map[string]string{} to nil because protojson omits empty maps. reflect.DeepEqual treats these as different, causing the dedup to fail and duplicate evaluations to appear in attestation results.

Closes #3017

…d-trip

Replace reflect.DeepEqual with maps.Equal for policy evaluation dedup
so nil and empty maps are treated as equivalent. protojson.Marshal omits
empty maps, causing deserialized With fields to be nil instead of empty,
which made the dedup comparison fail and duplicate evaluations appear.

Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Signed-off-by: Jose I. Paris <jiparis@chainloop.dev>
@jiparis jiparis requested a review from a team April 9, 2026 13:20
@jiparis jiparis changed the title fix(attestation): deduplicate policy evaluations after protojson round-trip fix(attestation): fix deduplication of policy evaluations Apr 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: duplicated policy evaluations in attestations

2 participants