Enhance topic change audit records with request details - #1901
Conversation
Ensure topic update, partition increase, and replication factor changes include their request details
|
AI Summary This issue addresses a gap in topic modification auditing where audit records lacked the submitted request details, making it difficult to track what changes were actually made—especially for topic config updates. The proposed solution enhances the audit context to include |
📝 WalkthroughWalkthroughTopicsController's updateTopic, increaseTopicPartitions, and changeReplicationFactor handlers now build AccessContext after the request body Mono resolves, attaching the DTO as operationParams and setting operationName. TopicsService exposes updateTopic publicly, removes an unused overload, and adds error handling to invalidate admin clients on config fetch errors. New controller tests validate this behavior. ChangesAccessContext Enrichment for Topic Mutations
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant TopicsController
participant AccessControlService
participant TopicsService
participant AuditService
Client->>TopicsController: Request body (TopicUpdate/PartitionsIncrease/ReplicationFactorChange)
TopicsController->>TopicsController: flatMap body Mono, build AccessContext with operationParams
TopicsController->>AccessControlService: validateAccess(context)
AccessControlService-->>TopicsController: validated
TopicsController->>TopicsService: execute mutation(cluster, topic, dto)
TopicsService-->>TopicsController: response DTO
TopicsController->>AuditService: audit(context)
TopicsController-->>Client: response
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Hi xyphoze! 👋
Welcome, and thank you for opening your first PR in the repo!
Please wait for triaging by our maintainers.
Please take a look at our contributing guide.
What changes did you make?
This PR improves the audit context for topic modification operations.
Previously, some topic modification audit records did not include the submitted request details. That we could see who changed a topic and which operation was performed, but not what was actually changed. This was especially limiting for topic config updates, where the audit record did not show which config keys were updated or what values they were changed to.
This change ensures the relevant request details are included in the audit context, so the actual topic changes can be reviewed later when investigating behavior, checking operational history, or tracing configuration changes.
There is still room for improvement. For example,
operationParamsshould ideally contain only the configs that were actually changed. However, that should be handled where the topic update params are created, rather than in the audit layer itself.How Has This Been Tested?
operationParams.TopicsControllerTestto verify that topic modification requests include request details in the audit/access context.Checklist
Check out Contributing and Code of Conduct
A picture of a cute animal (not mandatory but encouraged)

Photo by Skyler Ewing on Unsplash.
Summary by CodeRabbit