Fix error log during application deletion by reordering cache cleanup#3158
Fix error log during application deletion by reordering cache cleanup#3158Tharsanan1 wants to merge 1 commit intowso2-extensions:6.14.xfrom
Conversation
During service provider deletion, OAuthApplicationMgtListener.deleteAssociatedOAuthApps() deleted OAuth app data before cleaning cache entries. The cache cleanup calls OAuth2Util.isNonPersistentTokenEnabled() which looks up the OAuth app by consumer key, causing InvalidOAuthClientException since the app was already deleted. Reorder to clean cache entries before deleting OAuth app data so the lookup succeeds. Fixes: wso2/api-manager#4866 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ 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 |
| // Remove cache entries before deleting OAuth app data, since cache cleanup | ||
| // needs to look up app information that would no longer exist after deletion. | ||
| removeEntriesFromCache(associatedOAuthConsumerKeys); |
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
| // Remove cache entries before deleting OAuth app data, since cache cleanup | |
| // needs to look up app information that would no longer exist after deletion. | |
| removeEntriesFromCache(associatedOAuthConsumerKeys); | |
| // Remove cache entries before deleting OAuth app data, since cache cleanup | |
| // needs to look up app information that would no longer exist after deletion. | |
| log.info("Removing cache entries for OAuth apps associated with application: " + serviceProvider.getApplicationName() + ", tenantDomain: " + tenantDomain); | |
| removeEntriesFromCache(associatedOAuthConsumerKeys); |
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
| Comment | Accepted (Y/N) | Reason |
|---|---|---|
| #### Log Improvement Suggestion No: 1 |
Summary
InvalidOAuthClientException: application.not.foundERROR log emitted when deleting applications from DevportalOAuthApplicationMgtListener.deleteAssociatedOAuthApps()deleted OAuth app data before cleaning cache entries. The cache cleanup callsOAuth2Util.isNonPersistentTokenEnabled()which tries to look up the OAuth app by consumer key — but the app was already deletedremoveEntriesFromCache()to run beforeremoveOAuthApplicationData()so the lookup succeeds while app data still exists in the databaseRelated Issue
Fixes wso2/api-manager#4866
Test plan
DELETE /api/am/devportal/v3/applications/{appId}InvalidOAuthClientExceptionorapplication.not.founderrors inwso2carbon.log🤖 Generated with Claude Code