Skip to content

Conversation

@lucasbru
Copy link
Member

@lucasbru lucasbru commented Dec 1, 2025

The status field should always set in the response, even when empty, to
ensure that the status gets reset on the client.

We are not doing this due to an oversight - it is defined as nullable,
and it is null when not set. So status does not clear correctly on the
client, which ignores the field if it's null.

This can cause the streams application to incorrectly timeout, if the
source topic does not exist when the application is first started, but
it is created after the application started. Otherwise, there is no
noticable difference.

Reviewers: Lucas Brutschy [email protected]

The status field is now always set in the response, even when empty,
to ensure that the status gets reset on the client.
@lucasbru lucasbru requested review from Copilot and mjsax December 1, 2025 16:24
Copilot finished reviewing on behalf of lucasbru December 1, 2025 16:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes an issue where the status field in StreamsGroupHeartbeat responses was conditionally set only when non-empty. Since the field is nullable with a default of null, clients that ignore null values were unable to properly reset/clear the status. The fix ensures the status field is always set in the response, even when it's an empty list.

Key changes:

  • Removed conditional check before setting status field in responses
  • Added test to verify status field is always present

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/GroupMetadataManager.java Removed the if (!returnedStatus.isEmpty()) check, ensuring status is always set on the response even when empty
group-coordinator/src/test/java/org/apache/kafka/coordinator/group/GroupMetadataManagerTest.java Added test testStreamsGroupHeartbeatAlwaysSetsStatus to verify status field is always present in responses

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if (!returnedStatus.isEmpty()) {
response.setStatus(returnedStatus);
}
response.setStatus(returnedStatus);
Copy link

Copilot AI Dec 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code change to always set the status field will break many existing tests that don't expect .setStatus(List.of()) in responses when there are no status messages.

Looking at the test file, there are numerous tests (e.g., testMemberJoinsEmptyStreamsGroup at line 16265, testStreamsGroupHeartbeatPartialResponseWhenNothingChanges at line 17397, testStreamsUpdatingMemberMetadataTriggersNewTargetAssignment at line 16986, and many others) that create expected StreamsGroupHeartbeatResponseData objects without calling .setStatus(), which means the field defaults to null.

After this change, the actual responses will have .setStatus(List.of()) (an empty list), which won't equal null. This will cause test failures. All affected tests need to be updated to include .setStatus(List.of()) in their expected response objects.

Copilot uses AI. Check for mistakes.
@lucasbru lucasbru marked this pull request as draft December 1, 2025 16:56
@mjsax
Copy link
Member

mjsax commented Dec 2, 2025

Overall makes sense to me. Guess we might want to update the KIP for this case, so that the field is not nullable any longer?

@github-actions github-actions bot added core Kafka Broker clients and removed small Small PRs labels Dec 2, 2025
@lucasbru lucasbru marked this pull request as ready for review December 2, 2025 09:18
@lucasbru lucasbru merged commit 963d54a into apache:trunk Dec 5, 2025
20 checks passed
lucasbru added a commit to lucasbru/kafka that referenced this pull request Dec 5, 2025
apache#21031)

The status field should always set in the response, even when empty, to
ensure that the status gets reset on the client.

We are not doing this due to an oversight - it is defined as nullable,
and it is null when not set. So status does not clear correctly on the
client, which ignores the field if it's null.

This can cause the streams application to incorrectly timeout, if the
source topic does not exist when the application is first started, but
it is created after the application started. Otherwise, there is no
noticable difference.

Reviewers: Lucas Brutschy <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants