Skip to content

Fix error log during application deletion by reordering cache cleanup#3158

Draft
Tharsanan1 wants to merge 1 commit intowso2-extensions:6.14.xfrom
Tharsanan1:fix/issue-4866-clean
Draft

Fix error log during application deletion by reordering cache cleanup#3158
Tharsanan1 wants to merge 1 commit intowso2-extensions:6.14.xfrom
Tharsanan1:fix/issue-4866-clean

Conversation

@Tharsanan1
Copy link
Copy Markdown

Summary

  • Fixes spurious InvalidOAuthClientException: application.not.found ERROR log emitted when deleting applications from Devportal
  • Root cause: OAuthApplicationMgtListener.deleteAssociatedOAuthApps() deleted OAuth app data before cleaning cache entries. The cache cleanup calls OAuth2Util.isNonPersistentTokenEnabled() which tries to look up the OAuth app by consumer key — but the app was already deleted
  • Fix: Reorder removeEntriesFromCache() to run before removeOAuthApplicationData() so the lookup succeeds while app data still exists in the database

Related Issue

Fixes wso2/api-manager#4866

Test plan

  • Create an application in Devportal
  • Generate production OAuth keys for the application
  • Delete the application via DELETE /api/am/devportal/v3/applications/{appId}
  • Verify HTTP 200 response
  • Verify no InvalidOAuthClientException or application.not.found errors in wso2carbon.log
  • Verify OAuth app, service provider, and cache entries are properly cleaned up

🤖 Generated with Claude Code

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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 91439aef-1633-454e-9097-62b4be5a6303

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment on lines +212 to +214
// 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);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Log Improvement Suggestion No: 1

Suggested change
// 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);

Copy link
Copy Markdown
Contributor

@wso2-engineering wso2-engineering bot left a comment

Choose a reason for hiding this comment

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

AI Agent Log Improvement Checklist

⚠️ Warning: AI-Generated Review Comments

  • 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant