Skip to content

test(issues): pin plural @JsonTypeName for discussion events (guard #54)#62

Merged
johardi merged 1 commit into
mainfrom
fix/54-discussion-event-jsontypename-guard-tests
Jun 30, 2026
Merged

test(issues): pin plural @JsonTypeName for discussion events (guard #54)#62
johardi merged 1 commit into
mainfrom
fix/54-discussion-event-jsontypename-guard-tests

Conversation

@johardi

@johardi johardi commented Jun 30, 2026

Copy link
Copy Markdown
Member

Summary

Backend half of #54 (NEAR_MISS @JsonTypeName drift 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.CommentPosted
  • webprotege.events.discussions.CommentUpdated
  • webprotege.events.discussions.DiscussionThreadStatusChanged
  • webprotege.events.discussions.DiscussionThreadCreated

The expected values are hard-coded (not read from each class's CHANNEL constant) — 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)

DiscussionThreadCreated already 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 test4/4 pass.
  • tools/audit_json_conformance.py (run from the client repo) now reports NEAR_MISS=0 (was 2).

Related

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>
@johardi

johardi commented Jun 30, 2026

Copy link
Copy Markdown
Member Author

Companion client-side fix (the actual @JsonTypeName renames that resolve #54): protegeproject/webprotege-gwt-ui#275

@johardi johardi merged commit cdf509b into main Jun 30, 2026
1 check passed
@johardi johardi deleted the fix/54-discussion-event-jsontypename-guard-tests branch June 30, 2026 18:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant