Skip to content

Conversation

@abhimanyubabbar
Copy link
Collaborator

Description

Refactor the trackingplan provider to remove obsolete abstractions which were earlier added to handle expanding on the event and property references needed to send upsert requests to the trackingplan.

Given, we have moved away from the upsert requests to handling the requests with id references, the existing code is no longer required.

@codecov
Copy link

codecov bot commented Dec 14, 2025

Codecov Report

❌ Patch coverage is 18.66667% with 61 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.67%. Comparing base (29349e1) to head (cee1b8a).

Files with missing lines Patch % Lines
...ternal/providers/datacatalog/state/trackingplan.go 31.11% 29 Missing and 2 partials ⚠️
cli/internal/providers/datacatalog/provider.go 0.00% 30 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #320      +/-   ##
==========================================
+ Coverage   46.23%   46.67%   +0.43%     
==========================================
  Files         179      179              
  Lines       12943    12839     -104     
==========================================
+ Hits         5984     5992       +8     
+ Misses       6420     6307     -113     
- Partials      539      540       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

LocalID: event.ExternalID,
AllowUnplanned: event.AdditionalProperties,
IdentitySection: event.IdentitySection,
}
Copy link

Choose a reason for hiding this comment

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

Bug: Missing LocalID field breaks sorting and comparison

The LocalID field assignment (LocalID: event.ExternalID) was removed from TrackingPlanEventArgs in FromRemoteTrackingPlan, but utils.SortByLocalID(events) is still called on line 811. Since LocalID defaults to an empty string, all events will have identical empty LocalID values, making the sorting ineffective. This also breaks comparison between local and remote tracking plans, as FromCatalogTrackingPlan still sets LocalID while FromRemoteTrackingPlan no longer does. The sibling function TrackingPlanState.FromRemoteTrackingPlan correctly sets LocalID: remoteTPEvent.ExternalID.

Additional Locations (1)

Fix in Cursor Fix in Web


data := entityFromRef(eventRule.Event.Ref)
if data == nil {
return fmt.Errorf("unable to get event from ref: %s", eventRule.Event.Ref)
Copy link

Choose a reason for hiding this comment

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

Bug: Nil pointer dereference when processing include rules

The FromCatalogTrackingPlan function accesses eventRule.Event.IdentitySection and eventRule.Event.Ref without checking if eventRule.Event is nil. The TPRule struct supports rules with either Event or Includes fields (validated in required_keys.go), but the refactored code only handles the Event case. If a tracking plan contains rules with Includes instead of Event, this will cause a nil pointer dereference panic. The removed ExpandRefs function properly handled both cases with a switch statement.

Fix in Cursor Fix in Web

for _, props := range catalog.Properties {
for _, prop := range props {
propIDToURN[prop.LocalID] = resources.URN(prop.LocalID, pstate.PropertyResourceType)
propIDToProperty[prop.LocalID] = &prop
Copy link

Choose a reason for hiding this comment

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

Bug: Loop variable pointer causes all map entries to share same address

Taking the address of loop variables prop and event (&prop and &event) in the range loops causes all map entries in propIDToProperty and eventIDToEvent to point to the same memory location. In Go versions before 1.22, the loop variable is reused across iterations, so all entries will reference the last value processed. This causes getEntityFromRef to return incorrect property/event data for all lookups except the last one, resulting in tracking plans being created with wrong metadata.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We are on go 1.24 and this issue was fixed.

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.

1 participant