Skip to content

Commit 64813c7

Browse files
committed
Bug fix: Validate individual topics, not parent topic
Previously, the `validationDelegate()` was being prior to looping over children. As a result, the parent topic was being validated after it had already been mapped in order to determine if the children themselves should be mapped. There are scenarios where this makes sense, but is not the intuitive expectation and precludes quite a few scenarios. Further, the behavior was counter to the documentation. Notably, this made it very difficult to prevent one children among many from being excluded based on an attribute such as its content type since the logic was always evaluated on the parent. I.e., all children could be excluded based on their parent's attribute, but not based on their individual attributes. That's a far more likely scenario for most cases, and the one implied by the documentation. Technically, this bug fix could be a breaking change. As we have visibility into all current implementations of `HierarchicalTopicMappingService<T>`, however, we have high confidence that the only scenarios that this will break are internal to OnTopic, and don't affect any client implementations. And that makes sense, as it's likely that anyone attempting to implement this would have tripped over the unintuitive and even buggy logic, thus necessitating that this be patched previously.
1 parent d63f2b5 commit 64813c7

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

OnTopic/Mapping/Hierarchical/HierarchicalTopicMappingService{T}.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ private static int DistanceFromRoot(Topic? sourceTopic) {
189189
/*------------------------------------------------------------------------------------------------------------------------
190190
| Request mapping of children
191191
\-----------------------------------------------------------------------------------------------------------------------*/
192-
if (tiers >= 0 && validationDelegate(sourceTopic) && viewModel.Children.Count == 0) {
193-
foreach (var topic in sourceTopic.Children.Where(t => t.IsVisible())) {
192+
if (tiers >= 0 && viewModel.Children.Count == 0) {
193+
foreach (var topic in sourceTopic.Children.Where(t => t.IsVisible() && validationDelegate(t))) {
194194
taskQueue.Add(GetViewModelAsync(topic, tiers, validationDelegate));
195195
}
196196
}

0 commit comments

Comments
 (0)