test(issues): pin plural @JsonTypeName for discussion events (guard #54)#62
Merged
Merged
Conversation
Add contract-guard JSON tests that assert the on-the-wire @type discriminator for CommentPosted, CommentUpdated, DiscussionThreadStatusChanged, and DiscussionThreadCreated stays the canonical plural `webprotege.events.discussions.*` form. The expected values are hard-coded (not read from each class's CHANNEL constant) so the build fails if a discriminator ever drifts back to the singular `webprotege.events.discussion.*` form that was silently dropping these events on the wire. Refs #54 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Member
Author
|
Companion client-side fix (the actual |
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
Backend half of #54 (NEAR_MISS
@JsonTypeNamedrift in the discussion-event namespace).The backend already publishes all discussion events under the canonical plural
webprotege.events.discussions.*discriminator, so no production code change is needed here. This PR adds a contract-guard test that pins those discriminators so the plural ↔ singular drift described in #54 can never recur silently.What changed
New
DiscussionEventChannelJsonTest(@JsonTest) asserting the serialized$.['@type']of each discussion event equals the canonical plural string:webprotege.events.discussions.CommentPostedwebprotege.events.discussions.CommentUpdatedwebprotege.events.discussions.DiscussionThreadStatusChangedwebprotege.events.discussions.DiscussionThreadCreatedThe expected values are hard-coded (not read from each class's
CHANNELconstant) — asserting against the constant would let a rename slip through. The whole point is to fail the build if any of these strings change.Why
These events are routed across the JSON-RPC envelope by
@JsonTypeName. If a discriminator drifts, the consumer treats the message as an unknown type and drops it — no exception is thrown on either side. A build-time guard is the cheapest place to catch this class of bug.Decision recorded (per #54)
DiscussionThreadCreatedalready exists on the backend with the plural discriminator, so the canonical backend record is kept; the client is conformed to the plural form (companion PR). The issue's "client-only" note for this type was outdated relative to the current backend.Verification
mvn -Dtest=DiscussionEventChannelJsonTest test→ 4/4 pass.tools/audit_json_conformance.py(run from the client repo) now reportsNEAR_MISS=0(was 2).Related
@JsonTypeNamerenames): companion PR inprotegeproject/webprotege-gwt-ui(linked in a comment below).