Repository navigation
fix: Bind catalog execution deterministically and keep builder state - #2199
Merged
DaveSkender merged 1 commit intoAug 21, 2026
Merged
Conversation
Two defects in the catalog execution path, both reachable from the documented public API. ListingExecutionBuilder is a copy-on-write fluent builder, but WithParamValue and WithParams rebuilt it without carrying the source bars. Only one call order worked: setting parameters before the source. The natural reading of the API — pick the source, then configure it — dropped the bars and threw at Execute. Carry the source through every copy so order stops mattering. ListingExecutor selected an overload by argument count alone. ToGator has two arity-one overloads, one taking IReadOnlyList<IReusable> and one taking IReadOnlyList<AlligatorResult>, so which one ran was decided by Type.GetMethods order — documented as unspecified. The same call could bind differently across runtimes or builds, and the AlligatorResult overload rejects bars, so an unfavourable ordering throws. It happens to work today; nothing guarantees it keeps working. Prefer the candidate whose parameter types actually accept the assembled arguments. Generic definitions are left alone, since their parameter types are still open until the type argument is substituted. When a genuine tie remains, order candidates by declaring type and parameter types so the choice is reproducible rather than incidental. Both are covered by tests that compare catalog execution against the direct call, and both were mutation-tested: reverting the builder change reproduces "Bars must be set using From()", and simulating an unfavourable reflection order reproduces the AlligatorResult conversion failure. Fixes #2191 Fixes #2192
Contributor
|
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 13 |
| Duplication | 0 |
🟢 Coverage 78.13% diff coverage · -0.03% coverage variation
Metric Results Coverage variation ✅ -0.03% coverage variation (-1.00%) Diff coverage ✅ 78.13% diff coverage Coverage variation details
Coverable lines Covered lines Coverage Common ancestor commit (af18994) 19550 18868 96.51% Head commit (5c2543e) 19579 (+29) 18891 (+23) 96.49% (-0.03%) Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch:
<coverage of head commit> - <coverage of common ancestor commit>Diff coverage details
Coverable lines Covered lines Diff coverage Pull request (#2199) 32 25 78.13% Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified:
<covered lines added or modified>/<coverable lines added or modified> * 100%
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2191
Fixes #2192
#2191 — the builder dropped the source
ListingExecutionBuilderis copy-on-write, butWithParamValueandWithParamsrebuilt it without carrying_bars:Only one call order worked — parameters before source. The natural reading of a fluent API, pick the source then configure it, silently discarded the bars and threw at
Execute:docs/utilities/catalog.mdpresents these methods as freely chainable and says nothing about ordering. Now the source is carried through every copy, so order stops mattering.#2192 — overload chosen by unspecified order
ListingExecutorpicked by argument count alone.ToGatorhas two arity-one overloads —IReadOnlyList<IReusable>andIReadOnlyList<AlligatorResult>— soType.GetMethodsorder decided which ran, and that order is documented as unspecified.Worth being precise about the failure shape, because it is not the silent-wrong-value class of #2187. The
AlligatorResultoverload rejects bars, so an unfavourable ordering throws rather than miscomputing:It happens to bind favourably today. Nothing guarantees it keeps doing so across runtimes, target frameworks, or builds.
The fix prefers the candidate whose parameter types actually accept the assembled arguments. Generic method definitions are exempt from the check — their parameter types are still open until the type argument is substituted further down. When a genuine tie remains, candidates are ordered by declaring type and parameter types so the outcome is at least reproducible instead of incidental.
Verification
Both tests compare catalog execution against the direct call, so they assert the right overload ran rather than merely that something ran.
Mutation-tested in both directions:
Bars must be set using From() before calling Execute()LastOrDefault) → theAlligatorResultconversion failure aboveQuality gates:
Notes for review
WithParamValue/WithParamschange only in what they carry forward; the ordering that already worked still works.SelectByArityshort-circuits when there is one candidate, which is every listing except GATOR today — so the common path is unchanged.