fix: handle API product refs in key audit logs#15954
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a critical bug in the audit logging mechanism for API Product subscriptions. Previously, when an API Product subscription was paused, the system attempted to log an API reference that was null, leading to database errors. The changes introduce robust logic to correctly identify API Product subscriptions, use the appropriate reference ID, and call the specific audit log creation methods for API Products, thereby preventing data integrity issues and ensuring accurate auditing. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request enhances the audit logging mechanism within the ApiKeyServiceImpl. It introduces the API_PRODUCT audit property and refactors the createAuditLog method to correctly distinguish between API and API Product subscriptions. This ensures that audit events are logged using the appropriate service method (createApiProductAuditLog, createApiAuditLog, or createApplicationAuditLog) based on the subscription's reference type and ID. There is no feedback to provide.
b283b78 to
503f556
Compare
503f556 to
cf16bf2
Compare
...apim-rest-api-service/src/main/java/io/gravitee/rest/api/service/impl/ApiKeyServiceImpl.java
Outdated
Show resolved
Hide resolved
|



Issue
https://gravitee.atlassian.net/browse/APIM-13319
Description
Pausing an API Product subscription updates API keys and writes an audit entry. ApiKeyServiceImpl.createAuditLog always stored AuditProperties.API from subscription.getApi(), which is null for API Product subscriptions. That produced a NULL in audit_properties.value and failed the JDBC insert (NOT NULL).
Change
Resolve referenceId from referenceId with fallback to api.
For referenceType == API_PRODUCT, use API_PRODUCT in audit properties and createApiProductAuditLog; otherwise keep API and createApiAuditLog.