Skip to content

Fix parsing of UserUpdatedEvents#896

Open
pvancoeverden wants to merge 1 commit into
auth0:masterfrom
pvancoeverden:bugfix/SseEvents
Open

Fix parsing of UserUpdatedEvents#896
pvancoeverden wants to merge 1 commit into
auth0:masterfrom
pvancoeverden:bugfix/SseEvents

Conversation

@pvancoeverden

@pvancoeverden pvancoeverden commented Jul 10, 2026

Copy link
Copy Markdown

Changes

When I subscribed to UserUpdateEvents, all events are of the type: EventStreamSubscribeEventsResponseContent._UnknownValue, without readable data. This commit fixes this. Added a EventsSubscribeSseTest that shows the original problem.

References

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}

This is because the response is not parsed correctly: the value of all events are of type '_Unkown instead of the correct value

I've added the EventsSubscribeSseTest wich mimics the example code.

Please include relevant links supporting this change:

Testing

Please describe how this can be tested by reviewers. Be specific about anything not tested and reasons why. If this library has unit and/or integration testing, tests should be added for new functionality and existing tests should complete without errors.

  • This change adds test coverage
  • This change has been tested on the latest version of the platform/language or why not

Tested with java 21 in our own project, and build the unit-tests with java 17 because spotless did not work with my later java versions. (com.sun libs missing)

Checklist

@pvancoeverden pvancoeverden force-pushed the bugfix/SseEvents branch 2 times, most recently from 354a4ab to 566834a Compare July 10, 2026 21:54
When I subscribed to UserUpdateEvents, all events are of the type: `EventStreamSubscribeEventsResponseContent._UnknownValue, without readable data. This commit fixes this. Added a EventsSubscribeSseTest wich shows the original problem.
@pvancoeverden

Copy link
Copy Markdown
Author

Fixes #897

@pvancoeverden pvancoeverden marked this pull request as ready for review July 10, 2026 22:35
@pvancoeverden pvancoeverden requested a review from a team as a code owner July 10, 2026 22:35
@pvancoeverden

Copy link
Copy Markdown
Author

I realize now that some code is generated with Fern. But this project has no information how it is generated. I think it is better to fiddle with the api-spec and/or fern configuration to fix this bug.

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