File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -5276,13 +5276,20 @@ func init() {
52765276 apijson.RegisterUnion(
52775277 reflect.TypeOf((*SubscriptionUsageUnion)(nil)).Elem(),
52785278 "",
5279+ // Prefer the grouped variant when both variants appear equally exact.
5280+ // With both TypeFilters as gjson.JSON and no discriminator, the union
5281+ // resolver breaks ties left-to-right. Grouped responses include a
5282+ // `metric_group` field on each data element, which would otherwise be
5283+ // treated as an extra field by the ungrouped type, causing the ungrouped
5284+ // variant to win incorrectly. Listing the grouped variant first ensures
5285+ // grouped responses select the grouped type so metric_group is preserved.
52795286 apijson.UnionVariant{
52805287 TypeFilter: gjson.JSON,
5281- Type: reflect.TypeOf(SubscriptionUsageUngroupedSubscriptionUsage {}),
5288+ Type: reflect.TypeOf(SubscriptionUsageGroupedSubscriptionUsage {}),
52825289 },
52835290 apijson.UnionVariant{
52845291 TypeFilter: gjson.JSON,
5285- Type: reflect.TypeOf(SubscriptionUsageGroupedSubscriptionUsage {}),
5292+ Type: reflect.TypeOf(SubscriptionUsageUngroupedSubscriptionUsage {}),
52865293 },
52875294 )
52885295}
You can’t perform that action at this time.
0 commit comments