Skip to content
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

chore: autocommit feature branch #34062

Merged
merged 5 commits into from
Jun 10, 2024
Merged

chore: autocommit feature branch #34062

merged 5 commits into from
Jun 10, 2024

Conversation

sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Jun 7, 2024

Description

The changes are related to the "auto-commit" migration feature.
Server changes

  • Fixed issue with concurrent git calls for the same repo
  • Trigger issues with auto-commit

UI changes

  • Introduced new REST api for triggering auto-commit via client
  • Updated logic for saga to use trigger auto-commit api for checking whether to poll for auto-commit progress
  • Updated logic to make status api call blocking
  • Response structure change for auto-commit apis

Fixes #30110 #34067 #34068
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.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9419768186
Commit: 129eaee
Cypress dashboard url: Click here!

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Introduced enhanced Git autocommit functionality with improved error handling and progress tracking.
    • Added new autocommit actions and state management for better synchronization.
  • Bug Fixes

    • Improved error handling during Git synchronization processes.
  • Refactor

    • Updated method names and parameters for clarity and consistency in Git synchronization.
  • Chores

    • Renamed feature flags and constants related to Git autocommit for better readability and maintainability.

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Jun 7, 2024
Copy link
Contributor

coderabbitai bot commented Jun 7, 2024

Walkthrough

The changes enhance Git synchronization features by introducing new types, action creators, and methods for handling autocommit functionality. This includes tracking autocommit progress, error handling, and improving state management. Additionally, the feature flag for Git autocommit has been updated, and the Beta tag has been removed, signifying the feature's readiness for production.

Changes

File(s) Change Summary
app/client/src/actions/gitSyncActions.ts Added new types and action creators for autocommit functionality and error handling.
app/client/src/api/GitSyncAPI.tsx Introduced new enums, interfaces, and method for triggering autocommit.
app/client/src/ce/constants/ReduxActionConstants.tsx Renamed and added new constants related to Git autocommit functionality.
app/client/src/entities/Engine/AppEditorEngine.ts Updated the control flow to use new autocommit initiation actions.
app/client/src/pages/Editor/gitSync/QuickGitActions/BranchButton.tsx Added selectors to manage button states based on autocommit status.
app/client/src/reducers/uiReducers/gitSyncReducer.ts Added state variables and actions for managing autocommit triggering status.
app/client/src/sagas/GitSyncSagas.ts Restructured logic for handling autocommit progress, error actions, and state management.
app/client/src/selectors/gitSyncSelectors.tsx Added a new selector for retrieving autocommit triggering state.
app/server/.../FileUtilsCEImpl.java Modified methods to include new conditions for autocommit functionality.
app/server/.../FileOperationsCEv2Impl.java Updated feature flag name for autocommit functionality.
app/server/.../FeatureFlagEnum.java Replaced feature flag for autocommit eligibility.
app/server/.../FileInterface.java Added parameters for reconstructing metadata and pages from Git repo.
app/server/.../GitConstantsCE.java Added new constants for autocommit functionality.
app/server/.../GitController.java Included AutoCommitService as a new dependency.
app/server/.../GitControllerCE.java Renamed DTOs and adjusted method signatures for autocommit functionality.
app/server/.../AutoCommitResponseDTO.java Introduced a new DTO class for autocommit responses.
app/server/.../AutoCommitEventHandler.java Moved interface to a new package.
app/server/.../AutoCommitEventHandlerCEImpl.java Moved implementation to a new package and added import for GitRedisUtils.
app/server/.../AutoCommitService.java Introduced interface for autocommit service.
app/server/.../AutoCommitServiceCE.java Introduced interface for autocommit service with method for autocommitting applications.
app/server/.../AutoCommitServiceCEImpl.java Added class implementing autocommit service functionality.
app/server/.../AutoCommitServiceImpl.java Extended AutoCommitServiceCEImpl for autocommit functionality.
app/server/.../AutoCommitEligibilityHelper.java Added new method for checking client migration requirements.
app/server/.../AutoCommitEligibilityHelperFallbackImpl.java Added method for file system operations in autocommit eligibility.
app/server/.../AutoCommitEligibilityHelperImpl.java Updated method names, feature flags, and auto-commit eligibility logic.
app/server/.../GitAutoCommitHelper.java Updated method signatures and renamed methods for autocommit functionality.
app/server/.../AutoCommitEventHandlerImplTest.java Updated import paths and feature flag names in tests.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant UI
    participant GitSyncAPI
    participant GitSyncActions
    participant GitSyncSagas

    User->>UI: Enable Autocommit
    UI->>GitSyncActions: triggerAutocommitInitAction
    GitSyncActions->>GitSyncAPI: triggerAutocommit
    GitSyncAPI-->>GitSyncActions: Autocommit Response
    GitSyncActions->>GitSyncSagas: triggerAutocommitSuccessAction
    GitSyncSagas->>UI: Update UI with Autocommit Progress
Loading

Assessment against linked issues

Objective (Issue #30110) Addressed Explanation
Remove Beta tag from Git

Poem

In the land of code, where changes bloom,
Git sync now dances, shedding its Beta gloom.
Autocommit flows with grace and might,
Errors handled, progress in sight.
A rabbit's joy, in lines so neat,
Our code's now ready, a stable feat! 🌟🐇


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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 as 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.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

@sondermanish sondermanish added the ok-to-test Required label for CI label Jun 7, 2024
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: 13

Outside diff range and nitpick comments (5)
app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaVersions.java (1)

15-15: LGTM! It's good practice to document the specific changes that necessitated the version increment in the schema.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperFallbackImpl.java (1)

22-23: LGTM! Consider adding detailed logging in these fallback methods to aid in debugging when they are triggered.

Also applies to: 27-27

app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java (2)

38-38: Consider using import static for frequently used assertions to clean up the code.


122-126: This block effectively simulates the page DSL version fetching, which is central to the logic being tested. However, consider adding inline comments explaining why Boolean.TRUE is passed here.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java (1)

210-251: Review setup method for test consistency and completeness.

Consider adding comments to each block of the setup method to improve readability and maintainability.

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3177a4d and a6b7b50.

Files selected for processing (46)
  • app/client/src/actions/gitSyncActions.ts (3 hunks)
  • app/client/src/api/GitSyncAPI.tsx (2 hunks)
  • app/client/src/ce/constants/ReduxActionConstants.tsx (2 hunks)
  • app/client/src/entities/Engine/AppEditorEngine.ts (2 hunks)
  • app/client/src/pages/Editor/gitSync/QuickGitActions/BranchButton.tsx (5 hunks)
  • app/client/src/reducers/uiReducers/gitSyncReducer.ts (3 hunks)
  • app/client/src/sagas/GitSyncSagas.ts (6 hunks)
  • app/client/src/selectors/gitSyncSelectors.tsx (1 hunks)
  • app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java (2 hunks)
  • app/server/appsmith-git/src/main/java/com/appsmith/git/files/operations/FileOperationsCEv2Impl.java (6 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/enums/FeatureFlagEnum.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/FileInterface.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java (4 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/AutoCommitResponseDTO.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandler.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitService.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelper.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperFallbackImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperImpl.java (5 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelper.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperFallbackImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImpl.java (5 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCE.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/CommonGitFileUtils.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/GitUtils.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java (8 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaMigration.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/migrations/JsonSchemaVersions.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/ServerSchemaMigrationEnforcerTest.java (7 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerImplTest.java (4 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java (14 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java (8 hunks)
Files skipped from review due to trivial changes (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitService.java
  • app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ApplicationPageServiceCEImpl.java
Additional context used
Biome
app/client/src/sagas/GitSyncSagas.ts

[error] 709-709: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)

If it short-circuits with 'undefined' the evaluation will throw TypeError here:


[error] 837-837: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

Additional comments not posted (88)
app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandler.java (1)

1-1: Interface extension looks good and follows Java best practices.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCE.java (1)

1-9: Interface and method signature are well-defined and adhere to reactive programming principles.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerCE.java (1)

1-1: Interface and methods are well-defined, covering various aspects of auto-commit event handling.

Also applies to: 3-3

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelper.java (1)

3-3: Interface and methods are well-defined, covering various aspects of auto-commit operations.

Also applies to: 9-9, 15-15

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelper.java (1)

14-15: LGTM! The addition of isClientMigrationRequiredFSOps method enhances the granularity of migration checks.

app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java (1)

17-19: LGTM! The constructor now correctly injects AutoCommitService. Ensure that AutoCommitService is properly integrated and tested within the application.

Verification successful

The integration of AutoCommitService in GitController and GitControllerCE appears to be correctly implemented. The constructor in GitController now includes AutoCommitService, and GitControllerCE has a private final field for AutoCommitService. Additionally, there is a method toggleAutoCommitEnabled in GitControllerCE which likely utilizes this service.

  • GitController.java

    • Constructor: public GitController(CommonGitService service, AutoCommitService autoCommitService)
  • GitControllerCE.java

    • Field: private final AutoCommitService autoCommitService
    • Method: public Mono<ResponseDTO<Boolean>> toggleAutoCommitEnabled(@PathVariable String defaultApplicationId)
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of AutoCommitService in the application.

# Test: Search for the usage of AutoCommitService. Expect: Proper usage and handling.
rg --type java $'AutoCommitService'

Length of output: 1781



Script:

#!/bin/bash
# Extract method implementations in GitController.java and GitControllerCE.java to verify the usage of AutoCommitService.

# Search for methods in GitController.java
ast-grep --lang java --pattern $'class GitController {
  $$$
  $_($_) {
    $$$
  }
  $$$  
}' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java

# Search for methods in GitControllerCE.java
ast-grep --lang java --pattern $'class GitControllerCE {
  $$$
  $_($_) {
    $$$
  }
  $$$  
}' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java

Length of output: 382



Script:

#!/bin/bash
# Adjusted pattern to extract method implementations in GitController.java and GitControllerCE.java to verify the usage of AutoCommitService.

# Search for methods in GitController.java
ast-grep --lang java --pattern $'class GitController {
  $$$
  $_($$$) {
    $$$
  }
  $$$  
}' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java

# Search for methods in GitControllerCE.java
ast-grep --lang java --pattern $'class GitControllerCE {
  $$$
  $_($$$) {
    $$$
  }
  $$$  
}' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java

Length of output: 384



Script:

#!/bin/bash
# Use rg to search for method definitions and usages of AutoCommitService in GitController.java and GitControllerCE.java.

# Search for method definitions in GitController.java
rg --type java 'public .* {' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java

# Search for usages of AutoCommitService in GitController.java
rg --type java 'AutoCommitService' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java

# Search for method definitions in GitControllerCE.java
rg --type java 'public .* {' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java

# Search for usages of AutoCommitService in GitControllerCE.java
rg --type java 'AutoCommitService' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java

Length of output: 948



Script:

#!/bin/bash
# Corrected regex pattern to search for method definitions and usages of AutoCommitService in GitController.java and GitControllerCE.java.

# Search for method definitions in GitController.java
rg --type java 'public .*\{' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java

# Search for usages of AutoCommitService in GitController.java
rg --type java 'AutoCommitService' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/GitController.java

# Search for method definitions in GitControllerCE.java
rg --type java 'public .*\{' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java

# Search for usages of AutoCommitService in GitControllerCE.java
rg --type java 'AutoCommitService' app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java

Length of output: 2017

app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/CommonGitFileUtils.java (2)

21-27: Constructor parameters correctly match the superclass constructor.


4-5: Ensure that the new imports are utilized within the file.

Verification successful

The new imports FileOperations and ApplicationGitReference are both utilized within the CommonGitFileUtils.java file.

  • FileOperations is used as a constructor parameter.
  • ApplicationGitReference is used as a generic type parameter in ArtifactGitFileUtils.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the newly imported classes are used in the file.

# Test: Search for usage of `FileOperations` class. Expect: At least one occurrence.
rg --type java 'FileOperations' app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/CommonGitFileUtils.java

Length of output: 227



Script:

#!/bin/bash
# Description: Verify that the newly imported classes are used in the file.

# Test: Search for usage of `ApplicationGitReference` class. Expect: At least one occurrence.
rg --type java 'ApplicationGitReference' app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/CommonGitFileUtils.java

Length of output: 277

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperFallbackImpl.java (1)

26-30: The method isClientMigrationRequiredFSOps correctly returns a default value. Ensure it aligns with the intended fallback behavior.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/enums/FeatureFlagEnum.java (1)

18-27: Well-documented addition of the release_git_autocommit_eligibility_enabled feature flag.

app/server/appsmith-server/src/main/java/com/appsmith/server/dtos/AutoCommitResponseDTO.java (2)

12-43: Clear and comprehensive definitions for AutoCommitResponse enum states.


45-59: Proper use of Lombok annotations and well-structured DTO class.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/constants/ce/GitConstantsCE.java (1)

Line range hint 25-53: Appropriate addition of constants related to autocommit functionality.

app/client/src/pages/Editor/gitSync/QuickGitActions/BranchButton.tsx (2)

Line range hint 12-49: Effective use of selectors to manage UI state based on autocommit operations.


Line range hint 59-82: Proper handling of UI components state based on autocommit progress.

app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCE.java (1)

105-106: LGTM! The addition of findByApplicationIdAndApplicationMode method aligns well with the existing interface design.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/git/FileInterface.java (1)

57-67: LGTM! The addition of isResetToLastCommitRequired parameter in reconstructMetadataFromGitRepo method is a thoughtful enhancement for handling edge cases in git operations.

Verification successful

The integration of the new parameter isResetToLastCommitRequired in the reconstructMetadataFromGitRepo method has been verified in the following files:

  • CommonGitFileUtilsCE.java
  • FileUtilsCEImpl.java

Both files correctly include the new parameter in their method calls and implementations.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify integration of the modified method `reconstructMetadataFromGitRepo` with existing usages.

# Test: Search for the method usage. Expect: Adaptations of the new parameter in all usages.
rg --type java $'reconstructMetadataFromGitRepo'

Length of output: 471



Script:

#!/bin/bash
# Extract lines around the usage of `reconstructMetadataFromGitRepo` in `CommonGitFileUtilsCE.java`
rg --type java -A 5 -B 5 $'reconstructMetadataFromGitRepo' app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java

# Extract lines around the usage of `reconstructMetadataFromGitRepo` in `FileUtilsCEImpl.java`
rg --type java -A 5 -B 5 $'reconstructMetadataFromGitRepo' app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java

Length of output: 1235

app/server/appsmith-server/src/main/java/com/appsmith/server/services/ApplicationPageServiceImpl.java (1)

Line range hint 1-1: No changes to review in ApplicationPageServiceImpl.java.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCE.java (1)

108-109: LGTM! The addition of getAutoCommitProgress method supports the new auto-commit feature effectively.

Verification successful

The method getAutoCommitProgress is well-integrated into the codebase, with multiple references in both test and main Java files. Here are the key locations where the method is used:

  • CommonGitServiceCEImpl.java
  • AutoCommitServiceCEImpl.java
  • GitAutoCommitHelperFallbackImpl.java
  • GitAutoCommitHelperImpl.java
  • GitAutoCommitHelper.java
  • GitControllerCE.java

These references indicate that the method is properly integrated into the service layer and other relevant components.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify integration of the new method `getAutoCommitProgress` with existing usages.

# Test: Search for the method usage. Expect: Proper integration in the service layer.
rg --type java $'getAutoCommitProgress'

Length of output: 7397

app/client/src/api/GitSyncAPI.tsx (2)

46-65: Enums and interfaces for autocommit responses are well-defined.

The new enums and interfaces (AutocommitResponseEnum, GitAutocommitProgressResponse, GitTriggerAutocommitResponse) are clearly defined and align with the autocommit feature's requirements.


251-255: Method to trigger autocommit is correctly implemented.

The triggerAutocommit method correctly constructs the API endpoint and makes a POST request, aligning with the autocommit feature's functionality.

app/server/appsmith-git/src/main/java/com/appsmith/git/files/operations/FileOperationsCEv2Impl.java (1)

Line range hint 73-182: Feature-flagged methods for file operations are correctly implemented.

The methods (saveMetadataResource, saveWidgets, writeToFile, readFile, readFiles, getFileFormatVersion, getMainContainer) are correctly feature-flagged under release_git_autocommit_feature_enabled and include appropriate error handling and logging.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperImpl.java (1)

Line range hint 21-161: Methods to determine autocommit eligibility are correctly implemented.

The methods (isServerAutoCommitRequired, isClientMigrationRequired, isClientMigrationRequiredFSOps, isAutoCommitRequired) are correctly feature-flagged under release_git_autocommit_eligibility_enabled and include appropriate caching, error handling, and clear logic for determining autocommit necessity.

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

180-190: LGTM! Consider adding a comment explaining the use of org.json.JSONObject over net.minidev.json.JSONObject if this is intentional.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java (1)

46-146: The updates to autoCommitApplication enhance its functionality and maintainability. Good use of reactive programming and detailed logging.

app/client/src/selectors/gitSyncSelectors.tsx (1)

260-261: The addition of getIsTriggeringAutocommit follows existing selector patterns and is implemented correctly.

app/client/src/entities/Engine/AppEditorEngine.ts (1)

299-299: The addition of triggerAutocommitInitAction integrates well with the existing Git functionalities in the editor.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImpl.java (4)

9-9: Added import for AutoCommitResponseDTO.

This import is necessary for the new methods that utilize this DTO.


26-29: Added static imports for AutoCommitResponse enum values.

These imports simplify the usage of enum values in the code, enhancing readability.


130-130: Added @FeatureFlagged annotation to autoCommitServerMigration.

This ensures that the method is conditionally available based on the feature flag, which is a good practice for experimental or conditional features.


219-219: Added publishAutoCommitEvent method.

This method abstracts the logic to decide between client and server auto-commit, which simplifies the main auto-commit flow and enhances modularity.

app/client/src/actions/gitSyncActions.ts (3)

9-12: Added types related to Git auto-commit.

These types are necessary for the new auto-commit functionality and are correctly placed in the imports section.


486-486: Added toggleAutocommitEnabledInit action.

This action allows toggling the auto-commit feature from the UI, which is a necessary part of the feature's control mechanism.


496-536: Introduced a series of actions to manage auto-commit progress and errors.

These actions are essential for handling the state changes in the auto-commit process, including starting, stopping, and resetting progress, as well as handling errors.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerCEImpl.java (1)

16-16: Added import for GitRedisUtils.

This import is necessary for handling Redis operations related to Git, which are used extensively in the auto-commit process.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/AutoCommitEligibilityHelperTest.java (11)

106-106: Good practice to mock feature flags to control test behavior. This ensures tests remain deterministic.


111-111: Properly mocking Redis operations is crucial for isolating tests from external dependencies. Well done.


131-131: Mocking the server version check is key to testing the migration logic. This is a critical part of ensuring the auto-commit logic behaves as expected under different conditions.


216-220: This test setup is crucial for verifying the condition when only the server is eligible for auto-commit. The mocks are appropriately set to simulate this scenario.


249-249: This test checks the negative path where no server migration is required. It's important to cover both positive and negative scenarios in unit tests.


268-268: Testing the positive scenario for server migration requirement. It's good to see both edge cases being tested.


281-281: Mocking the feature flag to return FALSE effectively tests the scenario where the feature is disabled. This is a good practice to ensure feature flags are controlling the flow as expected.


297-304: This test method is well-structured to verify the client migration logic when the latest DSL version is not ahead. It's crucial to test these boundary conditions.


318-325: Testing the positive path for client migration requirement when the latest DSL version is ahead. This ensures that the migration logic is triggered correctly under the right conditions.


339-339: Effectively testing the scenario where the feature flag is off, ensuring that the system behaves correctly when the feature is disabled.


353-357: This comprehensive test checks the behavior when the feature flag is off, ensuring that no auto-commit is required. It's essential to test the feature flag's impact thoroughly.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImplTest.java (8)

11-11: Ensure the new import AutoCommitResponseDTO is utilized properly in the tests.


35-36: Usage of static imports for AutoCommitResponseDTO responses is good for readability.


246-253: Verify the progress of auto-commit when it is running.


262-270: Check auto-commit progress after completion ensures correct reset of state.


279-283: Correct handling of the scenario when no auto-commit is running.


364-364: Ensure that the feature flag check is correctly implemented in the context of server migrations.


402-402: This test should verify that the server does not require migration under the current settings, which is a critical check for stability.


339-339: The method autoCommitServerMigration should ensure that the feature flag for auto-commit is enabled before proceeding.

Verification successful

The search results show multiple instances of the autoCommitServerMigration method in both implementation and test files. However, the context provided does not clearly indicate whether the feature flag is checked before the method is called in the implementation files.

To ensure a thorough verification, we need to specifically check the implementation files for the presence of the feature flag check before calling autoCommitServerMigration.


The search results indicate that the autoCommitServerMigration method in GitAutoCommitHelperImpl.java is annotated with @FeatureFlagged(featureFlagName = FeatureFlagEnum.release_git_autocommit_feature_enabled). This annotation suggests that the feature flag is indeed checked before the method is executed.

Therefore, the concern mentioned in the review comment is addressed by the presence of the @FeatureFlagged annotation.

  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/helpers/GitAutoCommitHelperImpl.java
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the feature flag for auto-commit is checked before this method is called.

# Test: Search for the method usage. Expect: Feature flag check before the method call.
rg --type python $'autoCommitServerMigration'

Length of output: 75



Script:

#!/bin/bash
# Description: Verify that the feature flag for auto-commit is checked before the method `autoCommitServerMigration` is called.

# Test: Search for the method usage in Java files. Expect: Feature flag check before the method call.
rg --type java 'autoCommitServerMigration'

Length of output: 4277



Script:

#!/bin/bash
# Description: Verify that the feature flag for auto-commit is checked before the method `autoCommitServerMigration` is called.

# Extract and inspect the context around the method calls in the implementation files.
rg --type java 'autoCommitServerMigration' -A 5 -B 5

Length of output: 34396



Script:

#!/bin/bash
# Description: Verify that the feature flag for auto-commit is checked before the method `autoCommitServerMigration` is called in implementation files.

# Extract and inspect the context around the method calls in the implementation files.
rg --type java 'autoCommitServerMigration' -A 10 -B 10 | grep -E 'featureFlagService\.check|FeatureFlagEnum\.release_git_autocommit_feature_enabled'

Length of output: 1679

app/server/appsmith-server/src/main/java/com/appsmith/server/controllers/ce/GitControllerCE.java (4)

16-16: Ensure the new import AutoCommitResponseDTO is utilized properly in the controller methods.


25-25: The addition of AutoCommitService is crucial for the new auto-commit feature. Ensure it is injected and used correctly.


57-57: The autoCommitService is correctly injected into the controller, enabling the new auto-commit endpoints.


347-349: This endpoint fetches the progress of an auto-commit. It should correctly handle cases where no progress is available.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/ServerSchemaMigrationEnforcerTest.java (8)

3-6: The new imports related to ISOStringToInstantConverter and ModifiedResources are crucial for the tests. Ensure they are used correctly.


13-13: The addition of CachedFeatures is important for feature flag checks in tests.


18-18: FeatureFlagService is correctly mocked to control feature flag states during tests.


22-22: The custom Gson configuration with ISOStringToInstantConverter ensures correct serialization of Instant types.


Line range hint 207-240: This test ensures that importing and then exporting an application results in the same JSON, which is crucial for version control consistency.


296-338: This test checks for differences when re-saving files with different serialization logic. It's important for detecting unintended changes.


342-365: This test verifies that saving a file with the same serialization logic does not introduce diffs, which is crucial for data integrity.


369-423: This complex test simulates a full cycle of import, export, and git operations to ensure consistency and no unintended diffs.

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

Line range hint 326-367: Ensure consistent error handling in getMetadataServerSchemaMigrationVersion.

The method getMetadataServerSchemaMigrationVersion uses Mono.error for input validation but does not handle potential exceptions from reconstructMetadataFromRepo. Verify that all potential exceptions are handled consistently across the method.

Verification successful

The method reconstructMetadataFromRepo does include error handling using onErrorResume to handle potential exceptions. This ensures that any errors occurring during the reconstruction of metadata from the Git repository are managed consistently.

  • reconstructMetadataFromRepo handles errors using onErrorResume to wrap exceptions in AppsmithException.

This confirms that the error handling in getMetadataServerSchemaMigrationVersion is consistent, as it relies on reconstructMetadataFromRepo which already includes error handling.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify consistent error handling in `getMetadataServerSchemaMigrationVersion`.
rg --type java 'Mono.error' app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java

Length of output: 1434



Script:

#!/bin/bash
# Search for the definition of `reconstructMetadataFromRepo` and check its error handling.
ast-grep --lang java --pattern 'reconstructMetadataFromRepo($_, $_, $_, $_, $_, $_)' 

Length of output: 491



Script:

#!/bin/bash
# Search for the definition of `reconstructMetadataFromRepo` in the codebase.
ast-grep --lang java --pattern 'Mono<Map<String, Integer>> reconstructMetadataFromRepo($_, $_, $_, $_, $_, $_)' 

Length of output: 614



Script:

#!/bin/bash
# Correct the pattern syntax and search for the definition of `reconstructMetadataFromRepo` in the codebase.
ast-grep --lang java --pattern 'Mono<Map<String, Integer>> reconstructMetadataFromRepo($_, $_, $_, $_, $_, $_) { $$$ }' 

Length of output: 630



Script:

#!/bin/bash
# Simplify the pattern syntax and search for the definition of `reconstructMetadataFromRepo` in the codebase.
ast-grep --lang java --pattern 'reconstructMetadataFromRepo' 

Length of output: 411



Script:

#!/bin/bash
# Extract the definition of `reconstructMetadataFromRepo` from `CommonGitFileUtilsCE.java`.
sed -n '291,311p' app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java

Length of output: 1280

app/client/src/reducers/uiReducers/gitSyncReducer.ts (1)

58-58: Ensure correct handling of autocommit state transitions.

The changes correctly handle the state transitions for triggering autocommit. This includes setting the triggeringAutocommit flag appropriately during the initiation, success, and error phases, which is crucial for managing UI state in response to autocommit actions.

Also applies to: 623-634

app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerImplTest.java (1)

55-55: Verify correct feature flag handling in autocommit tests.

The tests correctly manipulate the release_git_autocommit_feature_enabled feature flag to simulate different scenarios. This is crucial for ensuring that the autocommit functionality behaves as expected under different feature flag settings.

Also applies to: 499-504, 537-537

app/server/appsmith-server/src/main/java/com/appsmith/server/newpages/base/NewPageServiceCEImpl.java (1)

691-708: The implementation of findByApplicationIdAndApplicationMode method correctly handles the filtering of pages based on their deletion status and application mode. Good use of functional programming paradigms.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/autocommit/AutoCommitServiceTest.java (10)

258-319: Review test method testAutoCommit_whenOnlyServerIsEligibleForMigration_commitSuccess.

The test method is well-structured and covers the scenario when only the server is eligible for migration. The assertions are correctly checking the expected outcomes.


321-391: Review test method testAutoCommit_whenOnlyClientIsEligibleForMigration_commitSuccess.

This test method correctly simulates the client-only migration scenario and validates the autocommit functionality through assertions.


394-447: Review test method testAutoCommit_whenAutoCommitNotEligible_returnsFalse.

The test method effectively handles the scenario where autocommit is not eligible, ensuring that the system remains in a consistent state without unnecessary commits.


450-470: Review test method testAutoCommit_whenAutoCommitAlreadyInProgressOnAnotherBranch_returnsLocked.

This test method correctly handles the scenario where an autocommit is already in progress on another branch, ensuring that the response is appropriately locked.


472-490: Review test method testAutoCommit_whenAutoCommitAlreadyInProgressOnSameBranch_returnsInProgress.

The test method is well-implemented to handle cases where an autocommit is already in progress on the same branch, and it correctly returns an 'IN_PROGRESS' status.


493-510: Review test method testAutoCommit_whenNoGitMetadata_returnsNonGitApp.

This test method is crucial for handling cases where no Git metadata is available, and it correctly identifies and handles such scenarios.


513-535: Review test method testAutoCommit_whenAutoCommitEligibleButPrerequisiteNotComplete_returnsRequired.

The test method effectively checks for prerequisites before proceeding with autocommit, ensuring that all conditions are met before making changes.


538-609: Review test method testAutoCommit_whenServerIsRunningMigrationCallsAutocommitAgainOnSameBranch_ReturnsAutoCommitInProgress.

This test method handles a complex scenario involving server migration and subsequent autocommit calls on the same branch, ensuring robustness in handling concurrent operations.


612-684: Review test method testAutoCommit_whenServerIsRunningMigrationCallsAutocommitAgainOnDiffBranch_ReturnsAutoCommitLocked.

This test method is well-structured to handle cases of server migration followed by an autocommit call on a different branch, ensuring that the system correctly locks the operation.


73-74: Ensure proper usage of @SpyBean for AutoCommitService.

app/client/src/sagas/GitSyncSagas.ts (6)

23-29: Ensure the newly imported types and enums are used correctly throughout the file.


48-54: Verify that the new actions are correctly dispatched and handled in their respective sagas.


1174-1188: The function isAutocommitHappening correctly evaluates the autocommit status from the response.


1261-1266: The saga triggerAutocommitSaga correctly manages the lifecycle of the autocommit polling process.


1289-1290: The mappings in gitRequestBlockingActions and gitRequestNonBlockingActions correctly associate git actions with their respective sagas.


1192-1256: The saga pollAutocommitProgressSaga effectively manages the polling of autocommit progress. However, ensure safe usage of optional chaining to prevent potential runtime errors.

Verification successful

The script successfully identified multiple instances of optional chaining usage across the codebase. However, to specifically verify the safe usage of optional chaining within the pollAutocommitProgressSaga function in app/client/src/sagas/GitSyncSagas.ts, we need to focus on that particular file.

Let's refine our search to only check for optional chaining within app/client/src/sagas/GitSyncSagas.ts.


The script output shows multiple instances of optional chaining usage within app/client/src/sagas/GitSyncSagas.ts. Specifically, the optional chaining in the pollAutocommitProgressSaga function appears to be used safely, as it checks for the existence of properties before accessing them.

Here are the relevant lines from the output:

  • app/client/src/sagas/GitSyncSagas.ts: if (isAutocommitHappening(triggerResponse?.data)) {
  • app/client/src/sagas/GitSyncSagas.ts: if (!isAutocommitHappening(progressResponse?.data)) {
  • app/client/src/sagas/GitSyncSagas.ts: error: progressResponse?.responseMeta?.error?.message,

These lines indicate that the optional chaining is used to safely access nested properties, ensuring that the code does not throw errors if any intermediate property is undefined or null.

Based on this analysis, the optional chaining usage in the pollAutocommitProgressSaga function is safe and does not pose any risk of runtime errors.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the safe usage of optional chaining in `pollAutocommitProgressSaga`.

# Test: Search for optional chaining usage. Expect: No occurrences that could result in undefined behavior.
rg --type typescript $'?.'

Length of output: 105



Script:

#!/bin/bash
# Description: Verify the safe usage of optional chaining in `pollAutocommitProgressSaga`.

# Test: Search for optional chaining usage. Expect: No occurrences that could result in undefined behavior.
rg --type typescript '\?\.'

Length of output: 64



Script:

#!/bin/bash
# Description: Verify the safe usage of optional chaining in `pollAutocommitProgressSaga`.

# Test: Search for optional chaining usage. Expect: No occurrences that could result in undefined behavior.
rg --glob '*.ts' '\?\.' 

Length of output: 206190



Script:

#!/bin/bash
# Description: Verify the safe usage of optional chaining in `pollAutocommitProgressSaga` within `app/client/src/sagas/GitSyncSagas.ts`.

# Test: Search for optional chaining usage in the specific file.
rg --glob 'app/client/src/sagas/GitSyncSagas.ts' '\?\.' 

Length of output: 5612

app/client/src/ce/constants/ReduxActionConstants.tsx (2)

134-135: New action types related to autocommit have been added correctly.


965-965: The addition of GIT_AUTOCOMMIT_TRIGGER_ERROR is appropriate for handling errors related to autocommit triggers.

Comment on lines +958 to +1015
String workspaceId,
String defaultArtifactId,
String repoName,
String branchName,
Path baseRepoSuffix,
Boolean isResetToLastCommitRequired) {
Mono<Object> metadataMono;
try {
// instead of checking out to last branch we are first cleaning the git repo,
// then checking out to the desired branch
metadataMono = gitExecutor
.resetToLastCommit(baseRepoSuffix, branchName)
.map(isSwitched -> {
Path baseRepoPath =
Paths.get(gitServiceConfig.getGitRootPath()).resolve(baseRepoSuffix);
Object metadata = fileOperations.readFile(
baseRepoPath.resolve(CommonConstants.METADATA + CommonConstants.JSON_EXTENSION));
return metadata;
});
Mono<Boolean> gitResetMono = Mono.just(Boolean.TRUE);
if (Boolean.TRUE.equals(isResetToLastCommitRequired)) {
// instead of checking out to last branch we are first cleaning the git repo,
// then checking out to the desired branch
gitResetMono = gitExecutor.resetToLastCommit(baseRepoSuffix, branchName);
}

metadataMono = gitResetMono.map(isSwitched -> {
Path baseRepoPath = Paths.get(gitServiceConfig.getGitRootPath()).resolve(baseRepoSuffix);
Object metadata = fileOperations.readFile(
baseRepoPath.resolve(CommonConstants.METADATA + CommonConstants.JSON_EXTENSION));
return metadata;
});
} catch (GitAPIException | IOException exception) {
metadataMono = Mono.error(exception);
}

return metadataMono.subscribeOn(scheduler);
}

@Override
public Mono<Object> reconstructPageFromGitRepo(
String pageName, String branchName, Path baseRepoSuffixPath, Boolean resetToLastCommitRequired) {
Mono<Object> pageObjectMono;
try {
Mono<Boolean> resetToLastCommit = Mono.just(Boolean.TRUE);

if (Boolean.TRUE.equals(resetToLastCommitRequired)) {
// instead of checking out to last branch we are first cleaning the git repo,
// then checking out to the desired branch
resetToLastCommit = gitExecutor.resetToLastCommit(baseRepoSuffixPath, branchName);
}

pageObjectMono = resetToLastCommit.map(isSwitched -> {
Path pageSuffix = Paths.get(PAGE_DIRECTORY, pageName);
Path repoPath = Paths.get(gitServiceConfig.getGitRootPath())
.resolve(baseRepoSuffixPath)
.resolve(pageSuffix);

Object pageObject =
fileOperations.readFile(repoPath.resolve(pageName + CommonConstants.JSON_EXTENSION));

return pageObject;
});
} catch (GitAPIException | IOException exception) {
pageObjectMono = Mono.error(exception);
}

return pageObjectMono.subscribeOn(scheduler);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Ensure proper error handling in reconstructMetadataFromGitRepo and reconstructPageFromGitRepo.

Both methods reconstructMetadataFromGitRepo and reconstructPageFromGitRepo catch GitAPIException and IOException but only return the error wrapped in a Mono. It would be beneficial to add logging before returning the error to aid in debugging and maintaining the application. Additionally, consider implementing a more robust error handling strategy that could include retries or alternative actions in case of failure.

// Suggested addition:
} catch (GitAPIException | IOException exception) {
    log.error("Failed to reset to last commit or read file: {}", exception.getMessage(), exception);
    metadataMono = Mono.error(exception);
}

Comment on lines +291 to +294
&& (modifiedResources.isAllModified()
|| !CollectionUtils.isEmpty(
modifiedResources.getModifiedResourceMap().get(CUSTOM_JS_LIB_LIST)))) {

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider optimizing the condition check for modified JS libraries.

The current condition checks for any modification in JS libraries using multiple method calls and conditions. This can be simplified and optimized by encapsulating the logic into a method that directly returns a boolean indicating if any JS library has been modified. This would make the code cleaner and potentially more efficient.

// Suggested refactor:
private boolean isJsLibModified(ModifiedResources modifiedResources) {
    return modifiedResources != null && (modifiedResources.isAllModified() || !CollectionUtils.isEmpty(modifiedResources.getModifiedResourceMap().get(CUSTOM_JS_LIB_LIST)));
}

// Usage in the method:
if (isJsLibModified(modifiedResources)) {
    // existing logic
}

Comment on lines +292 to +306
String workspaceId,
String applicationId,
String repoName,
String branchName,
Boolean isResetToLastCommitRequired,
ArtifactType artifactType) {

ArtifactGitFileUtils<?> artifactGitFileUtils = getArtifactBasedFileHelper(artifactType);
Path baseRepoSuffix = artifactGitFileUtils.getRepoSuffixPath(workspaceId, applicationId, repoName);

return fileUtils
.reconstructMetadataFromGitRepo(workspaceId, applicationId, repoName, branchName, baseRepoSuffix)
.reconstructMetadataFromGitRepo(
workspaceId, applicationId, repoName, branchName, baseRepoSuffix, isResetToLastCommitRequired)
.onErrorResume(error -> Mono.error(
new AppsmithException(AppsmithError.GIT_ACTION_FAILED, "checkout", error.getMessage())))
new AppsmithException(AppsmithError.GIT_ACTION_FAILED, CHECKOUT_BRANCH, error.getMessage())))
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider handling specific Git exceptions more granularly.

The method reconstructMetadataFromRepo uses a broad onErrorResume to handle all exceptions by wrapping them into an AppsmithException. It might be beneficial to handle specific Git-related exceptions separately to provide more detailed error messages or recovery options.

Comment on lines +60 to +79
public Mono<AutoCommitResponseDTO> getAutoCommitProgress(String defaultApplicationId, String branchName) {
return redisUtils
.getRunningAutoCommitBranchName(applicationId)
.zipWith(redisUtils.getAutoCommitProgress(applicationId))
.getRunningAutoCommitBranchName(defaultApplicationId)
.zipWith(redisUtils.getAutoCommitProgress(defaultApplicationId))
.map(tuple2 -> {
AutoCommitProgressDTO autoCommitProgressDTO = new AutoCommitProgressDTO(Boolean.TRUE);
autoCommitProgressDTO.setBranchName(tuple2.getT1());
autoCommitProgressDTO.setProgress(tuple2.getT2());
return autoCommitProgressDTO;
String branchNameFromRedis = tuple2.getT1();

AutoCommitResponseDTO autoCommitResponseDTO = new AutoCommitResponseDTO();
autoCommitResponseDTO.setProgress(tuple2.getT2());
autoCommitResponseDTO.setBranchName(branchNameFromRedis);

if (branchNameFromRedis.equals(branchName)) {
autoCommitResponseDTO.setAutoCommitResponse(IN_PROGRESS);
} else {
autoCommitResponseDTO.setAutoCommitResponse(LOCKED);
}

return autoCommitResponseDTO;
})
.defaultIfEmpty(new AutoCommitProgressDTO(Boolean.FALSE));
.defaultIfEmpty(new AutoCommitResponseDTO(IDLE));
Copy link
Contributor

Choose a reason for hiding this comment

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

Refactored getAutoCommitProgress to use AutoCommitResponseDTO.

This method now properly encapsulates the progress fetching logic using the DTO, which is a good practice for maintainability and clarity. Consider adding error handling for Redis operations.

Comment on lines +127 to +129
case 7:
applicationJson.setServerSchemaVersion(8);

Copy link
Contributor

Choose a reason for hiding this comment

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

Add migration logic or comments for schema version 7.

The case for schema version 7 only increments the server schema version to 8 without performing any migration steps. Please add the necessary migration logic or comments explaining why this version increment is needed.

@@ -1,7 +1,8 @@
package com.appsmith.server.git;
package com.appsmith.server.git.autocommit;
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The output indicates that the injected services are listed in the constructor parameters and passed to the superclass, but there is no evidence of their usage within the class methods. This suggests that the services might not be utilized within the AutoCommitEventHandlerImpl class.

To ensure that all injected services are used appropriately, the class methods should be reviewed for their usage. Since the script did not find any occurrences, it is likely that these services are not being used within the class methods.

  • : The injected services (GitRedisUtils, RedisUtils, DSLMigrationUtils, CommonGitFileUtils, GitExecutor, ProjectProperties, AnalyticsService) are not utilized within the AutoCommitEventHandlerImpl class methods. Please review and ensure that these services are used appropriately or remove them if they are not needed.
Analysis chain

Constructor parameters are correctly passed to the superclass. Ensure all injected services are utilized appropriately within the class.

Also applies to: 5-5


The script output shows that the injected services are imported and listed in the constructor parameters, but it does not confirm their usage within the class methods. To ensure that all injected services are utilized appropriately within the class, we need to search for their usage in the method bodies.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that the injected services are used in the class.

# Test: Search for usage of `GitRedisUtils` and other services. Expect: At least one occurrence for each.
rg --type java 'GitRedisUtils|RedisUtils|DSLMigrationUtils|CommonGitFileUtils|GitExecutor|ProjectProperties|AnalyticsService' app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerImpl.java

Length of output: 940



Script:

#!/bin/bash
# Description: Verify that the injected services are used in the class methods.

# Test: Search for usage of `gitRedisUtils`, `redisUtils`, `dslMigrationUtils`, `commonGitFileUtils`, `gitExecutor`, `projectProperties`, and `analyticsService` within the class methods.
rg --type java 'gitRedisUtils|redisUtils|dslMigrationUtils|commonGitFileUtils|gitExecutor|projectProperties|analyticsService' app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitEventHandlerImpl.java

Length of output: 775

Comment on lines +338 to +341
public Mono<ResponseDTO<AutoCommitResponseDTO>> autoCommitApplication(
@PathVariable String defaultApplicationId, @RequestHeader(name = FieldName.BRANCH_NAME) String branchName) {
return autoCommitService
.autoCommitApplication(defaultApplicationId, branchName)
Copy link
Contributor

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The autoCommitApplication method in AutoCommitServiceCEImpl.java does include error handling by returning Mono.error with appropriate exceptions when parameters are invalid or resources are not found. However, there is no explicit logging of these errors.

  • Ensure that errors are logged in the autoCommitApplication method in AutoCommitServiceCEImpl.java.
Analysis chain

This endpoint triggers the auto-commit for an application. Ensure that it handles errors gracefully and logs them.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify error handling in the auto-commit application endpoint.

# Test: Search for error handling logic. Expect: Proper error handling and logging.
rg --type python $'autoCommitApplication'

Length of output: 71



Script:

#!/bin/bash
# Description: Verify error handling in the auto-commit application endpoint in Java code.

# Test: Search for error handling logic within the autoCommitApplication method in GitControllerCE.java.
rg --type java 'autoCommitApplication' -A 20

Length of output: 81048



Script:

#!/bin/bash
# Description: Verify error handling in the auto-commit application service method in Java code.

# Test: Search for error handling logic within the autoCommitApplication method in AutoCommitServiceCEImpl.java.
rg --type java 'autoCommitApplication' -A 20 app/server/appsmith-server/src/main/java/com/appsmith/server/git/autocommit/AutoCommitServiceCEImpl.java

Length of output: 1356

@github-actions github-actions bot added Git Platform Issues related to the git & the app platform Git Product Issues related to version control product Task A simple Todo labels Jun 7, 2024
@brayn003
Copy link
Contributor

brayn003 commented Jun 7, 2024

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Jun 7, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9412345271.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 34062.
recreate: .

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 (2)
app/client/src/sagas/GitSyncSagas.ts (2)

Line range hint 714-714: Address potential TypeError due to unsafe optional chaining.

- const { mergeStatus } = response?.data;
+ const mergeStatus = response?.data?.mergeStatus;

Line range hint 842-842: Address potential TypeError due to unsafe optional chaining.

- const defaultPage = app.pages.find((eachPage) => !!eachPage.isDefault);
+ const defaultPage = app.pages?.find((eachPage) => !!eachPage.isDefault);
Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a6b7b50 and e3ca17f.

Files selected for processing (1)
  • app/client/src/sagas/GitSyncSagas.ts (8 hunks)
Additional context used
Biome
app/client/src/sagas/GitSyncSagas.ts

[error] 714-714: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)

If it short-circuits with 'undefined' the evaluation will throw TypeError here:


[error] 842-842: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

Additional comments not posted (5)
app/client/src/sagas/GitSyncSagas.ts (5)

23-29: Ensure correct import of AutocommitResponseEnum and related types.


48-54: Verify the correct implementation of new actions related to autocommit progress.


128-131: Ensure that the new types GitDiscardResponse and GitMetadata are correctly used within the sagas.


1179-1279: Review the implementation of triggerAutocommitSaga and related functions for handling autocommit.


1302-1303: Ensure that the new sagas for triggering autocommit are correctly registered in the action handlers.

Copy link

github-actions bot commented Jun 7, 2024

Deploy-Preview-URL: https://ce-34062.dp.appsmith.com

Copy link

github-actions bot commented Jun 7, 2024

Failed server tests

  • com.appsmith.server.solutions.DatasourceStructureSolutionTest#verifyDatasourceStorageStructureGettingSaved

@brayn003
Copy link
Contributor

brayn003 commented Jun 7, 2024

/build-deploy-preview skip-tests=true

Copy link

github-actions bot commented Jun 7, 2024

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/9413377443.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 34062.
recreate: .

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e3ca17f and b2278d6.

Files selected for processing (1)
  • app/client/src/sagas/GitSyncSagas.ts (9 hunks)
Additional context used
Biome
app/client/src/sagas/GitSyncSagas.ts

[error] 715-715: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)

If it short-circuits with 'undefined' the evaluation will throw TypeError here:


[error] 843-843: Unsafe usage of optional chaining. (lint/correctness/noUnsafeOptionalChaining)

If it short-circuits with 'undefined' the evaluation will throw TypeError here:

Additional comments not posted (9)
app/client/src/sagas/GitSyncSagas.ts (9)

23-28: Added new types for handling Git autocommit responses. Ensure these types are correctly used throughout the codebase.


48-54: Added new actions related to autocommit progress and error handling. Verify that these actions are dispatched correctly in the corresponding sagas.


118-118: Added a new selector for Git metadata. Ensure that this selector is used consistently where Git metadata is required.


129-132: Added new types for Git discard response and Git metadata. Ensure these types are correctly used throughout the codebase.


142-143: Added a new selector for feature flag checks. This is crucial for feature toggling and should be used to conditionally enable or disable features based on server-side configurations.


1180-1194: Added a new function isAutocommitHappening to check the status of autocommit. This function is critical for managing the state of autocommit operations. Ensure that it is used correctly in the sagas that handle autocommit.


1195-1262: Significant changes in pollAutocommitProgressSaga. This saga now handles the polling of autocommit progress and updates the state accordingly. Ensure that the error handling and state updates are robust and cover all edge cases.


1267-1282: Added triggerAutocommitSaga to handle the triggering of autocommit based on feature flags and autocommit settings. This is a critical piece of functionality that should be thoroughly tested to ensure it behaves as expected under various conditions.


1305-1307: Updated the mapping of Redux action types to sagas. This change is crucial for ensuring that the correct sagas are triggered for the corresponding actions. Verify that all mappings are correct and that no actions are left unhandled.

Copy link

github-actions bot commented Jun 7, 2024

Deploy-Preview-URL: https://ce-34062.dp.appsmith.com

@brayn003 brayn003 added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 7, 2024
@sondermanish sondermanish added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jun 7, 2024
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b2278d6 and 129eaee.

Files selected for processing (2)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Theme.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/ServerSchemaMigrationEnforcerTest.java (7 hunks)
Additional comments not posted (5)
app/server/appsmith-server/src/main/java/com/appsmith/server/domains/Theme.java (3)

41-41: The addition of the config field with appropriate JsonView annotations aligns well with existing fields. Good job maintaining consistency.


44-44: The properties field is correctly annotated and follows the pattern established by other theme attributes. This should enhance the theme's configurability.


47-47: The addition of the stylesheet field with JsonView annotations is a great enhancement for theme customization. It aligns with the visibility settings of similar fields.

app/server/appsmith-server/src/test/java/com/appsmith/server/git/ServerSchemaMigrationEnforcerTest.java (2)

3-6: The addition of new imports is justified as they support the new functionalities tested in this file, such as Git operations and feature flag checks.

Also applies to: 13-13, 18-18, 20-20, 22-22, 26-28, 30-30, 34-34


114-114: The addition of new test methods and the necessary setup in the test class are well-implemented. These changes are crucial for ensuring that schema migrations are handled correctly.

Also applies to: 117-117, 120-120, 126-126, 207-207, 296-296, 341-341, 368-368

@sondermanish sondermanish merged commit bf92a52 into release Jun 10, 2024
85 checks passed
@sondermanish sondermanish deleted the chore/autocommit branch June 10, 2024 07:05
@dvj1988 dvj1988 restored the chore/autocommit branch June 11, 2024 03:56
@dvj1988 dvj1988 deleted the chore/autocommit branch June 11, 2024 04:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Git Platform Issues related to the git & the app platform Git Product Issues related to version control product ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Task A simple Todo
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove Beta tag from Git
3 participants