Repository navigation
Don't fail scatter-gather when remote instances omit required members (e.g. EndpointDetails.Host) - #5961
Draft
speedmind wants to merge 2 commits into
Conversation
…nces EndpointDetails.Name/Host became 'required' in Particular#5774 (6.20.0). System.Text.Json enforces 'required' on deserialization, while audit instances serialize with WhenWritingNull and omit a null host. One such message made the primary fail the whole remote response, so the audit instance's page was dropped from scatter-gather queries (X-Particular-Incomplete-Results).
|
|
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Since 6.20.0, the primary instance can silently drop an entire audit instance's results from scatter-gather queries (for example
messages2, used by ServicePulse's "All messages" view and its endpoint filter). The response then carriesX-Particular-Incomplete-Results: <instance>:error, and the primary logsFailed to query remote instance ... missing required properties including: 'host'.This may be what's behind Particular/ServicePulse#3102.
Root cause
EndpointDetails.NameandEndpointDetails.Hostas C#required.requiredmembers on deserialization.DefaultIgnoreCondition = WhenWritingNull. The endpoint host is often null, for example when theNServiceBus.OriginatingMachineheader is missing and the originating address has no@machinepart, which is common on non-MSMQ transports. In that casehostis omitted from the JSON.ScatterGatherApi), one such message throws. Thecatchthen treats the whole instance as failed, so all of its results for that page are discarded.On 6.19.x these properties weren't
required, so the same payload deserialized fine.Fix
SerializerOptions.Default(primary instance) now adds aJsonTypeInfomodifier that setsIsRequired = falseon every property when reading JSON. C#requiredstill enforces correct construction in our own code. JSON that comes from other instances, possibly running other versions, is read the same way as before 6.20.Tests
RemoteEndpointDetailsDeserializationTests. It deserializes anEndpointDetailswithouthost, and runs a scatter-gather against a remote audit response that omitshost. Both tests fail on master without the fix: the first throws on the missing required property, and the second reports the remote instance as failed. Both pass with the fix.ServiceControl.UnitTestssuite: 453/453 passing locally. I haven't run the acceptance tests locally.The change applies cleanly to
release-6.21if a patch release is wanted.