Skip to content

chore: git changes for new contract#39376

Merged
sondermanish merged 2 commits intoreleasefrom
chore/git-changes
Feb 21, 2025
Merged

chore: git changes for new contract#39376
sondermanish merged 2 commits intoreleasefrom
chore/git-changes

Conversation

@sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Feb 20, 2025

Description

  • bug solutions and error handling

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13436821247
Commit: 4477846
Cypress dashboard.
Tags: @tag.Git
Spec:


Thu, 20 Feb 2025 14:40:06 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Artifact type information is now publicly visible in application responses.
  • Refactor
    • Enhanced repository and file operations with improved path validation, error handling, and updated dependency integration.
  • Tests
    • Updated test configurations to align with the revised dependency setup and file handling enhancements.

@sondermanish sondermanish requested a review from a team as a code owner February 20, 2025 08:07
@sondermanish sondermanish requested review from subrata71 and removed request for a team February 20, 2025 08:07
@sondermanish sondermanish self-assigned this Feb 20, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 20, 2025

Walkthrough

This pull request introduces significant modifications across several files related to Git operations. The changes include integrating a new dependency (FSGitHandler) in multiple classes, refactoring methods to support whitelisting of file paths, and renaming methods for clearer intent. Additionally, the PR updates error handling and modifies JSON view annotations to adjust information visibility. These changes affect both the core logic of file handling in Git repositories and associated test setups.

Changes

File(s) Change Summary
app/server/appsmith-git/.../FileUtilsCEImpl.java, FileUtilsImpl.java, FileUtilsImplTest.java Integrated new dependency FSGitHandler into constructors and methods; added protected whitelisting methods in FileUtilsCEImpl and updated calls in saveArtifactToGitRepo.
app/server/appsmith-server/.../ApplicationCE.java Changed JSON view annotation on getArtifactType from internal to public for broader exposure.
app/server/appsmith-server/.../GitFSServiceCEImpl.java, CommonGitFileUtilsCE.java Refactored repository update methods and error handling logic; renamed variables and methods (e.g., from moveArtifactFromTemporaryToBaseArtifactIdRepository to moveRepositoryFromTemporaryStorage) for improved clarity.
app/server/appsmith-server/.../ExchangeJsonConversionTests.java Replaced GitExecutor with FSGitHandler in test setup and mock behavior.

Possibly related PRs

  • chore: reverting the git branches it #38846: The changes in the main PR are related to the modifications in the FileUtilsCEImpl class, specifically regarding the handling of file operations and the introduction of the FSGitHandler.
  • chore: git branches IT  #38805: The changes in the main PR are related to the modifications in the FileUtilsCEImpl class, specifically the saveArtifactToGitRepo method, which is also referenced in the retrieved PR that alters the same method to improve file handling.
  • chore: merge and merge status #38495: The changes in the main PR are related to the modifications in the FileUtilsCEImpl class, specifically the addition of new methods and the integration of the FSGitHandler.

Suggested labels

Bug, Needs Triaging, Git Product, Packages & Git Pod

Suggested reviewers

  • nidhi-nair
  • subrata71

Poem

In code we trust with branches free,
New handlers bridge complexity.
Paths now guarded, errors embraced,
Git operations artfully traced.
A clever commit sings merrily! 🎉

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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.

@sondermanish sondermanish added the ok-to-test Required label for CI label Feb 20, 2025
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Feb 20, 2025
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

🧹 Nitpick comments (4)
app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java (3)

88-88: Visibility check.
Declaring fsGitHandler as protected suggests its usage in subclasses. Ensure this level of visibility is truly needed.


271-303: New whitelisting methods: getWhitelistedPaths and isWhiteListedPath.
These methods provide a clear approach for filtering paths. Consider:

  1. Documenting how this is updated if more whitelisted paths arise in future.
  2. Validating folder-depth edge cases.

305-305: Integrating whitelisted logic in getExistingFilesInRepo.
Invoking getWhitelistedPaths() at each call may be fine now, but if performance becomes a concern, cache the result.

app/server/appsmith-git/src/test/java/com/appsmith/git/helpers/FileUtilsImplTest.java (1)

35-36: Added FSGitHandler test field.
Ensure it’s properly mocked or initialized to cover all new logic in FileUtilsImpl.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9728e8b and 9b9b336.

📒 Files selected for processing (6)
  • app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java (6 hunks)
  • app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsImpl.java (2 hunks)
  • app/server/appsmith-git/src/test/java/com/appsmith/git/helpers/FileUtilsImplTest.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/ApplicationCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (2 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: server-unit-tests / server-unit-tests
🔇 Additional comments (15)
app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsCEImpl.java (6)

9-9: Good addition of the FSGitHandler import.
This aligns with the refactoring to delegate Git resets to FSGitHandler.


79-79: Ensure consistency of path delimiters.
Using DELIMITER_PATH from CommonConstantsCE is fine on Unix-like systems, but verify cross-platform compatibility (e.g., Windows) to avoid path resolution issues.


107-108: Constructor dependency injection update.
Injecting FSGitHandler improves modularity for file-system-related Git operations. No concerns here.


113-113: Field assignment clarity.
Assigning this.fsGitHandler = fsGitHandler; is straightforward. No issues.


252-269: Switching to fsGitHandler for resetToLastCommit.
Migrating the responsibility from gitExecutor to fsGitHandler is consistent with the new abstraction. Confirm that the resetToLastCommit logic remains equivalent and that any error handling needed is in place.


309-312: Filtering non-whitelisted files.
Appending the isWhiteListedPath check ensures only allowed paths remain. Looks correct for ignoring .git/ files.

app/server/appsmith-git/src/main/java/com/appsmith/git/files/FileUtilsImpl.java (3)

5-5: Importing FSGitHandler.
No issues. This facilitates consistent usage of the new handler throughout.


25-25: Adding FSGitHandler to the constructor signature.
Ensures this class stays in sync with the refactored superclass constructor.


30-30: Passing fsGitHandler to super.
Correctly forwards the parameter for the new file-system-based Git operations.

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

3-3: New import of FSGitHandler.
Indicates test coverage for fsGitHandler usage.


48-54: Updated constructor call in setUp.
Passing fsGitHandler is necessary for the new design. Confirm the mocking behavior if needed.

app/server/appsmith-server/src/main/java/com/appsmith/server/domains/ce/ApplicationCE.java (1)

371-374: LGTM! Making artifact type publicly visible is appropriate.

The change from @JsonView(Views.Internal.class) to @JsonView(Views.Public.class) for getArtifactType() is appropriate since it's a read-only value that identifies the type of artifact.

app/server/appsmith-server/src/main/java/com/appsmith/server/git/fs/GitFSServiceCEImpl.java (2)

218-226: LGTM! Path handling improvements.

The changes improve clarity by:

  • Renaming temporaryStorage to temporaryArtifactPath
  • Simplifying path construction to use only workspaceId and placeholder
  • Using the renamed moveRepositoryFromTemporaryStorage method

242-264: LGTM! Improved error handling structure.

The error handling refactoring enhances code clarity and maintainability by:

  • Separating concerns into distinct Mono variables
  • Using Mono.zip to properly combine operations
  • Providing clear error messages based on exception types
app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/CommonGitFileUtilsCE.java (1)

789-816: LGTM! Improved method naming and error handling.

The changes enhance code clarity and maintainability through:

  • More descriptive method name moveRepositoryFromTemporaryStorage
  • Better parameter names that reflect their purpose
  • Enhanced error logging with detailed path information

subrata71
subrata71 previously approved these changes Feb 20, 2025
@github-actions
Copy link

Failed server tests

  • com.appsmith.server.git.resourcemap.ExchangeJsonConversionTests#testSerializeArtifactExchangeJson_whenArtifactIsFullyPopulated_returnsCorrespondingBaseRepoPath(ExchangeJsonContext)[1]

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

🧹 Nitpick comments (1)
app/server/appsmith-server/src/test/java/com/appsmith/server/git/resourcemap/ExchangeJsonConversionTests.java (1)

132-144: Consider using temporary directory for test files.

The test creates and deletes directories in a hardcoded path. Consider using @TempDir or Files.createTempDirectory() for better test isolation and cleanup.

Example refactor:

-Files.createDirectories(Path.of("./container-volumes/git-storage/test123"));
+Path tempDir = Files.createTempDirectory("git-test");
+Path testPath = tempDir.resolve("test123");
+Files.createDirectories(testPath);

 Mono<Path> responseMono =
-        commonGitFileUtils.saveArtifactToLocalRepoNew(Path.of("test123"), originalArtifactJson, "irrelevant");
+        commonGitFileUtils.saveArtifactToLocalRepoNew(testPath, originalArtifactJson, "irrelevant");

-FileUtils.deleteDirectory(
-        Path.of("./container-volumes/git-storage/test123").toFile());
+FileUtils.deleteDirectory(tempDir.toFile());
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9b9b336 and 4477846.

📒 Files selected for processing (1)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/resourcemap/ExchangeJsonConversionTests.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: server-unit-tests / server-unit-tests
🔇 Additional comments (3)
app/server/appsmith-server/src/test/java/com/appsmith/server/git/resourcemap/ExchangeJsonConversionTests.java (3)

3-3: LGTM!

Clean import of the new FSGitHandler dependency.


55-55: LGTM!

Correct replacement of GitExecutor with FSGitHandler in the SpyBean annotation.


130-130: LGTM!

Mock behavior correctly updated to use FSGitHandler while maintaining the same return type and parameter structure.

@sondermanish sondermanish merged commit 98457f9 into release Feb 21, 2025
45 checks passed
@sondermanish sondermanish deleted the chore/git-changes branch February 21, 2025 07:19
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
## Description
- bug solutions and error handling

## Automation

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

### 🔍 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/13436821247>
> Commit: 4477846
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=13436821247&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Thu, 20 Feb 2025 14:40:06 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

- **New Features**
- Artifact type information is now publicly visible in application
responses.
- **Refactor**
- Enhanced repository and file operations with improved path validation,
error handling, and updated dependency integration.
- **Tests**
- Updated test configurations to align with the revised dependency setup
and file handling enhancements.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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 skip-changelog Adding this label to a PR prevents it from being listed in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants