rishi-rana opened a new pull request, #23379: URL: https://github.com/apache/kafka/pull/23379
## Summary `kafka-metadata-shell` does not show the default user-principal quota (or the default client-id/IP quotas), even though `kafka-configs.sh --describe` shows them correctly. `ClientQuotaEntity`'s javadoc states that a `null` entity name denotes the built-in default entity, and that's exactly how default quotas are represented in the metadata image (`ClientQuotaImage.dataToEntity`, sourced from the nullable `EntityName` field of `ClientQuotaRecord`). `ClientQuotasImageNode#clientQuotaEntityToString` only appended an entity segment (`user(...)`, `clientId(...)`, `ip(...)`) when that entity's value was non-null. For a default entity, the value is `null`, so the check silently skipped it — for a single-entry default entity (e.g. just `user=null`) this produced an empty child name, and `ls` effectively lost the entry. `decodeEntity` had the mirrored gap: it never produced a `null` value, so navigating back into a default entity by name (`user()`) could not match the corresponding key already present in the image. ## Fix - Track whether each entity type (`clientId`/`ip`/`user`) was present independently of its (possibly `null`) value, and render an empty name for a `null`/default value instead of omitting the segment. - Treat an empty parsed name in `decodeEntity` as the default (`null`) value, so it round-trips to the same key used in `ClientQuotasImage`. - Updated the existing default-entity round-trip tests to use `null` values (matching real production data) instead of empty strings, since `Map.of` can't hold `null` and the tests were previously exercising a case the shell doesn't actually hit. - Added a regression test at the `ClientQuotasImageNode` level reproducing the reported scenario: listing and navigating into a default user-principal quota entity. ## Test plan - `./gradlew :metadata:test --tests "org.apache.kafka.image.node.ClientQuotasImageNodeTest"` — all 16 tests pass, including the new regression test. - `./gradlew :metadata:checkstyleMain :metadata:checkstyleTest :metadata:spotlessCheck` — clean. ## AI assistance disclosure Per `AI_POLICY`/`CONTRIBUTING.md`: Claude Code (Sonnet 5) was used to investigate the root cause, implement the fix, and write the tests in `metadata/src/main/java/org/apache/kafka/image/node/ClientQuotasImageNode.java` and `metadata/src/test/java/org/apache/kafka/image/node/ClientQuotasImageNodeTest.java`. All changes were reviewed by me before submission. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01K4B9PPesZhXHiWr5Ak1PNz -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
