-
Notifications
You must be signed in to change notification settings - Fork 168
Introduce a new API for debugging purposes #1033
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| * Gets the debug service using OSGi service lookup. | ||
| * | ||
| * @return Debug service instance if available, null otherwise. | ||
| */ |
There was a problem hiding this comment.
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
| */ | |
| public static Object getDebugService() { | |
| log.info("Attempting to retrieve DebugService via OSGi lookup"); |
| Object debugService = getDebugService(); | ||
| if (debugService == null) { | ||
| log.warn("DebugService not available for method invocation: " + methodName); | ||
| return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 2
| return null; | |
| try { | |
| if (log.isDebugEnabled()) { | |
| log.debug("Invoking method '" + methodName + "' on DebugService with " + | |
| (arguments != null ? arguments.length : 0) + " arguments"); | |
| } |
|
|
||
| @Activate | ||
| protected void activate(ComponentContext context) { | ||
| try { | ||
| log.info("API Debug Service Component activated successfully"); | ||
| log.info("Ready to provide debug framework service lookup for API layer"); | ||
|
|
||
| } catch (Exception e) { | ||
| log.error("Error while activating API Debug Service Component", e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 3
| @Activate | |
| protected void activate(ComponentContext context) { | |
| try { | |
| log.info("API Debug Service Component activated successfully"); | |
| log.info("Ready to provide debug framework service lookup for API layer"); | |
| } catch (Exception e) { | |
| log.error("Error while activating API Debug Service Component", e); | |
| } | |
| @Activate | |
| protected void activate(ComponentContext context) { | |
| try { | |
| log.info("API Debug Service Component activated successfully"); | |
| log.info("Ready to provide debug framework service lookup for API layer"); | |
| } catch (Exception e) { | |
| log.error("Error while activating API Debug Service Component: " + e.getMessage()); | |
| } |
|
|
||
| @Deactivate | ||
| protected void deactivate(ComponentContext context) { | ||
| try { | ||
| log.info("API Debug Service Component deactivated successfully"); | ||
| } catch (Exception e) { | ||
| log.error("Error while deactivating API Debug Service Component", e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 4
| @Deactivate | |
| protected void deactivate(ComponentContext context) { | |
| try { | |
| log.info("API Debug Service Component deactivated successfully"); | |
| } catch (Exception e) { | |
| log.error("Error while deactivating API Debug Service Component", e); | |
| } | |
| @Deactivate | |
| protected void deactivate(ComponentContext context) { | |
| try { | |
| log.info("API Debug Service Component deactivated successfully"); | |
| } catch (Exception e) { | |
| log.error("Error while deactivating API Debug Service Component: " + e.getMessage()); | |
| } |
|
|
||
| @PathParam("session-id") String sessionId) { | ||
| String resultJson = org.wso2.carbon.identity.debug.framework.DebugResultCache.get(sessionId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 5
| @PathParam("session-id") String sessionId) { | |
| String resultJson = org.wso2.carbon.identity.debug.framework.DebugResultCache.get(sessionId); | |
| @PathParam("session-id") String sessionId) { | |
| log.info("Retrieving debug result for session ID: " + sessionId); | |
| String resultJson = org.wso2.carbon.identity.debug.framework.DebugResultCache.get(sessionId); |
| @ApiParam(value = "Debug connection request", required = true) | ||
| @Valid DebugConnectionRequest debugConnectionRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 6
| @ApiParam(value = "Debug connection request", required = true) | |
| @Valid DebugConnectionRequest debugConnectionRequest) { | |
| @Valid DebugConnectionRequest debugConnectionRequest) { | |
| log.info("Debugging connection for IdP ID: " + idpId); | |
| return delegate.debugConnection(idpId, debugConnectionRequest); |
| public Response debugConnection(String idpId, DebugConnectionRequest debugConnectionRequest) { | ||
| try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 7
| public Response debugConnection(String idpId, DebugConnectionRequest debugConnectionRequest) { | |
| try { | |
| public Response debugConnection(String idpId, DebugConnectionRequest debugConnectionRequest) { | |
| if (LOG.isDebugEnabled()) { | |
| LOG.debug("Debug connection initiated for IdP: " + idpId); | |
| } | |
| try { |
|
|
||
| // Create OAuth 2.0 response. | ||
| DebugConnectionResponse response = createOAuth2Response(oauth2Result, idpId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 8
| // Create OAuth 2.0 response. | |
| DebugConnectionResponse response = createOAuth2Response(oauth2Result, idpId); | |
| // Create OAuth 2.0 response. | |
| DebugConnectionResponse response = createOAuth2Response(oauth2Result, idpId); | |
| LOG.info("Successfully generated OAuth 2.0 authorization URL for IdP: " + idpId); | |
| return Response.ok(response).build(); |
| */ | ||
| public Response debugConnection(String idpId, DebugConnectionRequest debugConnectionRequest) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 9
| */ | |
| public Response debugConnection(String idpId, DebugConnectionRequest debugConnectionRequest) { | |
| public Response debugConnection(String idpId, DebugConnectionRequest debugConnectionRequest) { | |
| LOG.info("Debug connection initiated for IdP: " + (idpId != null ? idpId.replaceAll("[\r\n]", "") : "null")); | |
| try { |
| ); | ||
|
|
||
| // Create OAuth 2.0 response. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 10
| ); | |
| // Create OAuth 2.0 response. | |
| // Create OAuth 2.0 response. | |
| DebugConnectionResponse response = createOAuth2Response(oauth2Result, normalizedIdpId); | |
| LOG.info("Successfully generated OAuth 2.0 authorization URL for IdP: " + normalizedIdpId.replaceAll("[\r\n]", "")); | |
| return Response.ok(response).build(); |
| } | ||
|
|
||
| public void setTestUser(String testUser) { | ||
| this.testUser = testUser; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 11
| } | |
| public void setTestUser(String testUser) { | |
| this.testUser = testUser; | |
| public void setTestUser(String testUser) { | |
| if (testUser != null && !testUser.isEmpty()) { | |
| log.debug("Setting test user for debug request"); | |
| } | |
| this.testUser = testUser; | |
| } |
|
|
||
| public void setDebugMode(String debugMode) { | ||
| this.debugMode = debugMode; | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 12
| public void setDebugMode(String debugMode) { | |
| this.debugMode = debugMode; | |
| } | |
| public void setDebugMode(String debugMode) { | |
| if (debugMode != null) { | |
| log.info("Debug mode set to: " + debugMode); | |
| } | |
| this.debugMode = debugMode; | |
| } |
| * @return OAuth 2.0 authorization URL and session information. | ||
| */ | ||
| public Map<String, Object> generateOAuth2AuthorizationUrl(String idpId, String authenticatorName, | ||
| String redirectUri, String scope, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 13
| * @return OAuth 2.0 authorization URL and session information. | |
| */ | |
| public Map<String, Object> generateOAuth2AuthorizationUrl(String idpId, String authenticatorName, | |
| String redirectUri, String scope, | |
| public Map<String, Object> generateOAuth2AuthorizationUrl(String idpId, String authenticatorName, | |
| String redirectUri, String scope, | |
| Map<String, String> additionalParams) { | |
| log.info("Generating OAuth 2.0 authorization URL for IdP: " + idpId); |
| throw new RuntimeException("OAuth 2.0 authorization URL not found in context"); | ||
| } | ||
|
|
||
| // Build response with URL and session information. | ||
| Map<String, Object> result = new HashMap<>(); | ||
| result.put("sessionId", sessionDataKey); | ||
| result.put("authorizationUrl", authorizationUrl); | ||
| result.put("status", "URL_GENERATED"); | ||
| result.put("message", "OAuth 2.0 authorization URL generated successfully. " + | ||
| "Redirect user to this URL for authentication."); | ||
| result.put("idpName", idpName != null ? idpName : "Unknown"); | ||
| result.put("authenticatorName", targetAuthenticator != null ? targetAuthenticator : "Unknown"); | ||
| // Add executor class name for clarity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 14
| throw new RuntimeException("OAuth 2.0 authorization URL not found in context"); | |
| } | |
| // Build response with URL and session information. | |
| Map<String, Object> result = new HashMap<>(); | |
| result.put("sessionId", sessionDataKey); | |
| result.put("authorizationUrl", authorizationUrl); | |
| result.put("status", "URL_GENERATED"); | |
| result.put("message", "OAuth 2.0 authorization URL generated successfully. " + | |
| "Redirect user to this URL for authentication."); | |
| result.put("idpName", idpName != null ? idpName : "Unknown"); | |
| result.put("authenticatorName", targetAuthenticator != null ? targetAuthenticator : "Unknown"); | |
| // Add executor class name for clarity | |
| // Build response with URL and session information. | |
| Map<String, Object> result = new HashMap<>(); | |
| result.put("sessionId", sessionDataKey); | |
| result.put("authorizationUrl", authorizationUrl); | |
| result.put("status", "URL_GENERATED"); | |
| result.put("message", "OAuth 2.0 authorization URL generated successfully. " + | |
| "Redirect user to this URL for authentication."); | |
| result.put("idpName", idpName != null ? idpName : "Unknown"); | |
| result.put("authenticatorName", targetAuthenticator != null ? targetAuthenticator : "Unknown"); | |
| // Add executor class name for clarity | |
| String executorClass = executer != null ? executer.getClass().getSimpleName() : "UnknownExecutor"; | |
| result.put("executor", executorClass); | |
| result.put("timestamp", System.currentTimeMillis()); | |
| log.info("Successfully generated OAuth 2.0 authorization URL for IdP: " + idpName); |
There was a problem hiding this 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
- 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.
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Tip 📝 Customizable high-level summaries are now available in beta!You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.
Example instruction:
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later. 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 |
Purpose
Issue: wso2/product-is#25534
Goals
Approach
User stories
Developer Checklist (Mandatory)
product-isissue to track any behavioral change or migration impact.Release note
Documentation
Automation tests
Security checks
Samples
Related PRs
Migrations (if applicable)
Test environment