Event Streams SSE subscription always deserializes events to `_UnknownValue`
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 25/100
Research direction
Start at managementApi().events().subscribe(...) and inspect the unit test and potential fix in linked pull request #896. Verify that emitted events populate typed variants such as getUserUpdated() or getOffsetOnly() rather than always becoming _UnknownValue, and run the regression test against the SSE response handling.
Written by the indexing model from the issue text.
Description
Checklist
- I have looked into the Readme and Examples, and have not found a suitable solution or answer.
- I have looked into the API documentation and have not found a suitable solution or answer.
- I have searched the issues and have not found a suitable solution or answer.
- I have searched the Auth0 Community forums and have not found a suitable solution or answer.
- I agree to the terms within the Auth0 Code of Conduct.
Description
When subscribing to the Event Streams SSE endpoint via managementApi().events().subscribe(...), every emitted event is deserialized to EventStreamSubscribeEventsResponseContent._UnknownValue with type: null and value: null, regardless of the actual event type. The typed variants (e.g. getUserUpdated(), getOffsetOnly()) are therefore never populated, and _isUnknown() is always true, so consumers have no way to read the event payload.
I've created a PR that shows the bug with an unit-test and a potential fix: https://github.com/auth0/auth0-java/pull/896
Reproduction
Example code to reproduce the bug:
private void connect()
{
final SubscribeEventsRequestParameters.Builder settings = SubscribeEventsRequestParameters.builder()
.eventType(EventStreamSubscribeEventsEventTypeEnum.USER_UPDATED);
final Optional<String> offset = syncService.getOffset(EVENT_TYPE_KEY);
if (offset.isPresent())
{
settings.from(offset.get());
}
else
{
settings.fromTimestamp(startOfDay());
}
log.info("Subscribing to Auth0 user.updated event stream (resuming from {})", offset.map(o -> "offset " + o).orElse("start of day"));
final Iterable<EventStreamSubscribeEventsResponseContent> stream = apiProvider.getManagementApi().events().subscribe(settings.build());
try
{
for (EventStreamSubscribeEventsResponseContent event : stream)
{
try
{
handleEvent(event);
}
catch (Exception e)
{
// A single malformed event must not tear down the whole stream.
log.error("Failed to handle Auth0 event", e);
}
}
}
finally
{
closeQuietly(stream);
}
}
private void handleEvent(EventStreamSubscribeEventsResponseContent event)
{
if (event.getUserUpdated().isPresent())
{
handleUserUpdated(event.getUserUpdated().get());
return;
}
if (event.getOffsetOnly().isPresent())
{
handleOffsetOnly(event.getOffsetOnly().get());
return;
}
if (event._isUnknown())
{
log.warn("Received unknown Auth0 event type, ignoring: {}", event);
}
}
All events will print Received unknown Auth0 event type, ignoring: EventStreamSubscribeEventsResponseContent{type: null, value: null}
(Trigger update-events by updating users in Auth0)
I've also created a unit test that reproduces the bug.
https://github.com/auth0/auth0-java/pull/896/changes#diff-7bcc14b70df7dcbb2aeae35c7e142483c5d1cf4117239559729c1a41b312139d
Additional context
No response
auth0-java version
3.10.0
Java version
21
- Dominant language
- Java
- Stars
- 319
- Forks
- 155
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 12
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from auth0/auth0-java
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
auth0/auth0-java#887 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
auth0/auth0-java#842 · 2 comments ·
-
bug
Difficulty 5/5 Over a week Newbie friendliness 35/100
auth0/auth0-java#911 ·
-
feature request
Difficulty 1/5 Under an hour Newbie friendliness 50/100
auth0/auth0-java#754 · 2 comments ·
All issues in auth0/auth0-java
Similar issues
-
awaiting triage bug Causes friction Hop Gui P1 P2 Transforms
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/flink-agents#1152 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
jenkinsci/blueocean-plugin#5417 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
objectionary/eo-graphs#75 ·