Keep attribution consistent with vendor links
Three paths could leave a catalog row's attribution out of step with its common_third_party_id. A FIRST_PARTY reclassification in the mapping worker kept a stale org ThirdParty link instead of clearing it. The upsert requeued terminal FIRST_PARTY rows for enrichment on a vendor they never adopt, since the vendor-preservation clause nulls it. And the proboctl upsert command did not normalize the verdict when an operator linked or unlinked a vendor without passing --attribution. Clear the org link on a first-party verdict, exclude FIRST_PARTY rows from the enrichment requeue, and have the CLI downgrade THIRD_PARTY to UNDETERMINED on unlink and promote UNDETERMINED to THIRD_PARTY on link. Signed-off-by: Émile Ré <emile@probo.com>
This commit is contained in:
@@ -158,6 +158,18 @@ func newCmdUpsert(f *cmdutil.Factory) *cobra.Command {
|
||||
if cmd.Flags().Changed("common-third-party") {
|
||||
if flagCommonThirdParty == "" {
|
||||
pattern.CommonThirdPartyID = nil
|
||||
|
||||
// Removing the vendor invalidates a THIRD_PARTY
|
||||
// verdict, which by definition carries one. When the
|
||||
// operator did not set an explicit --attribution,
|
||||
// downgrade the now-stale verdict to UNDETERMINED so
|
||||
// the mapping pipeline probes the vendor-free row
|
||||
// again. A FIRST_PARTY row is already vendor-free and
|
||||
// terminal, so it is left untouched.
|
||||
if !cmd.Flags().Changed("attribution") &&
|
||||
pattern.Attribution == coredata.CommonTrackerPatternAttributionThirdParty {
|
||||
pattern.Attribution = coredata.CommonTrackerPatternAttributionUndetermined
|
||||
}
|
||||
} else {
|
||||
thirdPartyID, err := resolveCommonThirdPartyID(ctx, tx, flagCommonThirdParty)
|
||||
if err != nil {
|
||||
@@ -165,6 +177,19 @@ func newCmdUpsert(f *cmdutil.Factory) *cobra.Command {
|
||||
}
|
||||
|
||||
pattern.CommonThirdPartyID = &thirdPartyID
|
||||
|
||||
// A vendor-linked row is, by definition, attributed to
|
||||
// a third party. When the operator did not set an
|
||||
// explicit --attribution, normalize the verdict to
|
||||
// THIRD_PARTY so the row never persists with an
|
||||
// UNDETERMINED (or unset) verdict. A FIRST_PARTY row is
|
||||
// terminal and stays vendor-free — the upsert discards
|
||||
// the incoming vendor and keeps the verdict — so it is
|
||||
// left untouched.
|
||||
if !cmd.Flags().Changed("attribution") &&
|
||||
pattern.Attribution != coredata.CommonTrackerPatternAttributionFirstParty {
|
||||
pattern.Attribution = coredata.CommonTrackerPatternAttributionThirdParty
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user