Skip to content

base changes to populate system info to executeActionDTO#37091

Merged
nsarupr merged 4 commits intoreleasefrom
chore/refactor/ce-ee-populate-system-info
Oct 31, 2024
Merged

base changes to populate system info to executeActionDTO#37091
nsarupr merged 4 commits intoreleasefrom
chore/refactor/ce-ee-populate-system-info

Conversation

@nsarupr
Copy link
Contributor

@nsarupr nsarupr commented Oct 25, 2024

Description

This PR is the base change for adding any system related info to the ExecuteActionDTO.

Fixes #Issue Number
or
Fixes Issue URL

Warning

If no issue exists, please create an issue first, and check with the maintainers if the issue is valid.

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11610567421
Commit: 2f5ab4b
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 31 Oct 2024 11:33:58 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a new interface and implementation for enhanced action execution solutions.
    • Added functionality to populate action execution data with system and user information.
  • Bug Fixes

    • Improved structure and maintainability of action execution logic.
  • Tests

    • Updated test class to include a mock for the new action execution helper, ensuring future compatibility.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 25, 2024

Walkthrough

A set of changes has been made to introduce new interfaces and classes related to action execution solutions within the com.appsmith.server.helpers package. The new ActionExecutionSolutionHelper interface extends the existing ActionExecutionSolutionHelperCE, while the ActionExecutionSolutionHelperImpl class implements this interface. Additionally, a new method for populating action DTOs with system information has been added to streamline the execution process. Modifications to the ActionExecutionSolutionCEImpl class also enhance its functionality by integrating the new helper.

Changes

File Change Summary
.../ActionExecutionSolutionHelper.java New interface ActionExecutionSolutionHelper added, extending ActionExecutionSolutionHelperCE.
.../ActionExecutionSolutionHelperImpl.java New class ActionExecutionSolutionHelperImpl added, implementing ActionExecutionSolutionHelper.
.../ce/ActionExecutionSolutionHelperCE.java New interface ActionExecutionSolutionHelperCE added with method populateExecuteActionDTOWithSystemInfo.
.../ce/ActionExecutionSolutionHelperCEImpl.java New class ActionExecutionSolutionHelperCEImpl added, implementing ActionExecutionSolutionHelperCE with the method populateExecuteActionDTOWithSystemInfo.
.../ce/ActionExecutionSolutionCEImpl.java Constructor updated to include ActionExecutionSolutionHelper, method populateExecuteActionDTO refactored to use the helper. New method populateExecuteActionDTOWithUserId added.
.../solutions/ce/ActionExecutionSolutionCEImplTest.java MockBean for ActionExecutionSolutionHelper added, constructor signature updated to include the new helper.

Possibly related PRs

Suggested labels

Task, IDE Product, IDE Pod, skip-changelog

Suggested reviewers

  • sharat87
  • abhvsn
  • AnaghHegde

🎉 In the realm of code, new helpers arise,
With interfaces and classes, they reach for the skies.
Action execution, now smooth as can be,
A dance of DTOs, in harmony, you see!
So let’s celebrate this code, oh so bright,
For in every line, there’s a spark of delight! 🌟


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 79849be and 2f5ab4b.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Outside diff range and nitpick comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ActionExecutionSolutionHelperCE.java (1)

6-8: Add Javadoc documentation for the interface and method.

The interface and method would benefit from Javadoc documentation explaining their purpose and contract.

Apply this diff:

+/**
+ * Helper interface for populating system information in action execution DTOs.
+ */
 public interface ActionExecutionSolutionHelperCE {
+    /**
+     * Populates the provided ExecuteActionDTO with system information.
+     * @param executeActionDTO The DTO to be populated
+     * @return A Mono containing the populated ExecuteActionDTO
+     */
     Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO);
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ActionExecutionSolutionHelperImpl.java (1)

6-8: Consider adding Javadoc for maintainability.

While the implementation is correct, adding class-level documentation would improve maintainability.

 @Component
+/**
+ * Implementation of ActionExecutionSolutionHelper that extends the CE implementation.
+ * Handles population of system information into executeActionDTO.
+ */
 public class ActionExecutionSolutionHelperImpl extends ActionExecutionSolutionHelperCEImpl
         implements ActionExecutionSolutionHelper {}
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ActionExecutionSolutionHelperCEImpl.java (1)

10-10: Add method documentation.

Add Javadoc to describe the method's purpose, parameters, return value, and any potential exceptions.

+/**
+ * Populates the provided ExecuteActionDTO with system information.
+ *
+ * @param executeActionDTO the DTO to be populated with system information
+ * @return Mono<ExecuteActionDTO> the populated DTO
+ * @throws IllegalArgumentException if executeActionDTO is null
+ */
 @Override
 public Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO) {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 56ef430 and 4955c00.

📒 Files selected for processing (6)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ActionExecutionSolutionHelper.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ActionExecutionSolutionHelperImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ActionExecutionSolutionHelperCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ActionExecutionSolutionHelperCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java (5 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ActionExecutionSolutionHelper.java
🔇 Additional comments (7)
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ActionExecutionSolutionHelperCE.java (1)

1-8: LGTM! The interface follows reactive patterns and naming conventions.

The interface is well-structured with:

  • Clear CE (Community Edition) naming pattern
  • Appropriate use of reactive programming with Mono
  • Descriptive method name and parameter
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ActionExecutionSolutionHelperImpl.java (1)

1-8: Implementation follows the CE pattern correctly.

The class structure properly extends the CE implementation while allowing for enterprise-specific overrides if needed.

Let's verify the CE implementation to ensure all required methods are present:

✅ Verification successful

Implementation and CE pattern are correctly structured and implemented

The verification confirms:

  • CE interface defines single method populateExecuteActionDTOWithSystemInfo
  • CE implementation provides the base functionality
  • Main class properly extends and implements the required hierarchy
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the CE implementation and interface
# Look for the base CE implementation and interface
rg -A 10 "class ActionExecutionSolutionHelperCEImpl"
rg -A 10 "interface ActionExecutionSolutionHelperCE"

Length of output: 1539

app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/ActionExecutionSolutionHelperCEImpl.java (1)

1-13: Consider adding unit tests.

As this is a new class implementing core functionality, ensure comprehensive unit tests are added to verify the system information population.

app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImplTest.java (2)

136-137: LGTM! Mock bean properly integrated.

The ActionExecutionSolutionHelper mock bean is correctly added following Spring testing conventions.


169-170: LGTM! Constructor parameter properly updated.

The new helper is correctly injected while maintaining the existing dependency injection pattern.

app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java (2)

37-37: LGTM: Clean dependency injection implementation.

The ActionExecutionSolutionHelper dependency is properly injected and initialized.

Also applies to: 123-123, 152-153, 173-173


252-266: LGTM: Well-structured refactoring to helper class.

The refactoring improves separation of concerns by delegating system info population to the helper class while maintaining the reactive programming model.

Comment on lines +10 to +12
public Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO) {
return Mono.just(executeActionDTO);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Add implementation to populate system information.

The current implementation returns the DTO without populating any system information, which doesn't fulfill the PR objective of populating system info into executeActionDTO.

Consider adding system information like:

 @Override
 public Mono<ExecuteActionDTO> populateExecuteActionDTOWithSystemInfo(ExecuteActionDTO executeActionDTO) {
-    return Mono.just(executeActionDTO);
+    return Mono.just(executeActionDTO)
+        .map(dto -> {
+            // Add relevant system information
+            // Example: OS, Java version, etc.
+            return dto;
+        })
+        .switchIfEmpty(Mono.error(new IllegalArgumentException("ExecuteActionDTO cannot be null")));
 }

Committable suggestion was skipped due to low confidence.

Comment on lines +268 to +274
/**
* Populates the requestParams with logged in userId.
* If the user is not logged in, set the parameter as anonymousUserId
*
*/
protected Mono<ExecuteActionDTO> populateExecuteActionDTOWithUserId(ExecuteActionDTO executeActionDTO) {
return Mono.just(executeActionDTO);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Implementation doesn't match method's documented behavior.

The method is documented to populate the userId but currently returns the DTO unmodified. This could lead to unexpected behavior.

Consider implementing the documented behavior:

protected Mono<ExecuteActionDTO> populateExecuteActionDTOWithUserId(ExecuteActionDTO executeActionDTO) {
-    return Mono.just(executeActionDTO);
+    return sessionUserService.getCurrentUser()
+            .map(user -> {
+                executeActionDTO.setUserId(user.getId());
+                return executeActionDTO;
+            })
+            .defaultIfEmpty(executeActionDTO);
}

Committable suggestion was skipped due to low confidence.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Outside diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java (1)

Line range hint 1-68: Consider documenting the ActionExecutionSolutionHelper's responsibilities

The introduction of ActionExecutionSolutionHelper appears to be a good separation of concerns. Consider adding class-level documentation to explain its role in system info population and its interaction with ActionExecutionSolution.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 4955c00 and 79849be.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java (3 hunks)
🔇 Additional comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java (3)

7-7: LGTM: Import added for new dependency

The import statement for ActionExecutionSolutionHelper is correctly placed with other helper imports.


65-66: LGTM: Super constructor call matches parameter order

The super constructor call correctly passes all parameters in the same order as they are received.


44-45: Verify constructor parameter ordering

The new parameters are added at the end of the constructor, which is good practice for backward compatibility. However, let's verify that this ordering is consistent across the inheritance chain.

✅ Verification successful

Constructor parameter ordering is consistent across inheritance chain

The constructor parameter ordering in ActionExecutionSolutionImpl matches exactly with its parent class ActionExecutionSolutionCEImpl. The new parameters commonConfig and actionExecutionSolutionHelper are added at the end of both constructors and passed correctly through the super call, maintaining backward compatibility.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Check the constructor parameter ordering in parent class
ast-grep --pattern 'class ActionExecutionSolutionCEImpl {
  $$$
  ActionExecutionSolutionCEImpl($$$) {
    $$$
  }
}'

Length of output: 119


Script:

#!/bin/bash
# Let's try a broader search to find the parent class and its constructor
rg -l "ActionExecutionSolutionCEImpl" 

# Then let's look at both implementation files
rg "class ActionExecutionSolution.*Impl.*constructor|class ActionExecutionSolution.*Impl.*\(" -A 10

Length of output: 465


Script:

#!/bin/bash
# Let's directly examine the content of both implementation files
cat app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ActionExecutionSolutionImpl.java
echo "----------------------------------------"
cat app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java

Length of output: 63780

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.solutions.ce.ActionExecutionSolutionCEImplTest#testExecuteAPIWithUsualOrderingOfTheParts

@nidhi-nair nidhi-nair marked this pull request as draft October 29, 2024 06:44
@nsarupr nsarupr marked this pull request as ready for review October 31, 2024 08:46
@nsarupr nsarupr added the ok-to-test Required label for CI label Oct 31, 2024
sondermanish
sondermanish previously approved these changes Oct 31, 2024
Copy link
Contributor

@sondermanish sondermanish left a comment

Choose a reason for hiding this comment

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

looks good, please run the appropriate tests before merging

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.solutions.ce.ActionExecutionSolutionCEImplTest#testExecuteAPIWithUsualOrderingOfTheParts

@nsarupr
Copy link
Contributor Author

nsarupr commented Oct 31, 2024

looks good, please run the appropriate tests before merging

No test cases are required at this point, as this is vanilla placeholder for changes.

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.solutions.ce.ActionExecutionSolutionCEImplTest#testExecuteAPIWithUsualOrderingOfTheParts

Copy link
Collaborator

@subrata71 subrata71 left a comment

Choose a reason for hiding this comment

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

Looks good to me! Just ensure you add JavaDoc comments to provide context for the reader, including the purpose of embedding system info and the types of system info being embedded.

@nsarupr nsarupr merged commit a647668 into release Oct 31, 2024
@nsarupr nsarupr deleted the chore/refactor/ce-ee-populate-system-info branch October 31, 2024 11:40
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…#37091)

## Description
> This PR is the base change for adding any system related info to the
ExecuteActionDTO.

Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/11610567421>
> Commit: 2f5ab4b
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11610567421&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Thu, 31 Oct 2024 11:33:58 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **New Features**
- Introduced a new interface and implementation for enhanced action
execution solutions.
- Added functionality to populate action execution data with system and
user information.

- **Bug Fixes**
	- Improved structure and maintainability of action execution logic.

- **Tests**
- Updated test class to include a mock for the new action execution
helper, ensuring future compatibility.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants