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

fix: added edge case fixes for consolidated api and publishing #37399

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

sondermanish
Copy link
Contributor

@sondermanish sondermanish commented Nov 15, 2024

Description

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.Git"

🔍 Cypress test results

Tip

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


Fri, 15 Nov 2024 07:01:40 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced handling of Git operations, including improved branch management and artifact importation.
    • Expanded analytics integration for tracking changes in branch protection settings.
  • Bug Fixes

    • Improved error handling for various Git operations and application/page retrieval scenarios.
  • Tests

    • Added new test cases for Git-related functionalities and improved error handling in tests.
    • Enhanced test coverage for the getConsolidatedInfoForPageLoad method, particularly for feature branches.

@sondermanish sondermanish requested a review from a team as a code owner November 15, 2024 06:01
@sondermanish sondermanish requested review from subrata71 and removed request for a team November 15, 2024 06:01
Copy link
Contributor

coderabbitai bot commented Nov 15, 2024

Walkthrough

The pull request introduces significant modifications to the CommonGitServiceCEImpl and ConsolidatedAPIServiceCEImpl classes, focusing on improving Git operations, error handling, and analytics integration. Key updates include refactored methods for branch management and artifact importation, enhanced error handling mechanisms, and the addition of new test cases to cover various scenarios. The getConsolidatedInfoForPageLoad method has been refined to better handle Git-connected applications, with improved data processing and error logging.

Changes

File Change Summary
app/server/appsmith-server/src/main/java/com/appsmith/server/git/common/CommonGitServiceCEImpl.java Refactored methods for branch management, artifact importation, and error handling; updated method signatures for clarity; enhanced analytics integration.
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java Modified getConsolidatedInfoForPageLoad method to improve application and page retrieval logic for Git-connected applications; enhanced error handling.
app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java Added new test cases for Git functionalities, improved error handling tests, and refined mock behaviors for Git operations; expanded branch management tests.
app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java Introduced a new test method to validate behavior of getConsolidatedInfoForPageLoad with feature branches; enhanced error handling and response validation tests.

Possibly related PRs

Suggested labels

Bug, Task, Query & JS Pod, Git Product, ok-to-test, Needs Triaging

Suggested reviewers

  • nidhi-nair
  • abhvsn
  • sharat87

🎉 In the realm of code, changes unfold,
With Git's dance and stories told.
Branches merge, and errors mend,
In tests, we find our trusty friend.
So raise a cheer for the code we write,
Enhancing our app, making it bright! ✨


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.

@sondermanish sondermanish self-assigned this Nov 15, 2024
@github-actions github-actions bot added the Bug Something isn't working label Nov 15, 2024
@sondermanish sondermanish added the ok-to-test Required label for CI label Nov 15, 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: 2

🧹 Outside diff range and nitpick comments (3)
app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java (1)

1526-1540: Simplify redundant doReturn calls in mock setup

The consecutive doReturn(Mono.just(samplePageDTO)) calls can be simplified to a single call since they return the same value.

Apply this diff to simplify the mock setup:

-        doReturn(Mono.just(samplePageDTO))
-                .doReturn(Mono.just(samplePageDTO))
-                .when(spyApplicationPageService)
-                .getPageAndMigrateDslByBranchedPageId(anyString(), anyBoolean(), anyBoolean());

+        doReturn(Mono.just(samplePageDTO))
+                .when(spyApplicationPageService)
+                .getPageAndMigrateDslByBranchedPageId(anyString(), anyBoolean(), anyBoolean());
app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java (2)

2028-2029: Adjust the indentation of inline comments for clarity.

The comments on lines 2028-2029 are misaligned, which may affect readability. Please align the comments properly to maintain code readability.


2031-2031: Ensure consistency in assertion messages.

On line 2031, consider adding a descriptive message to the assertion to provide clearer test failure information.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 6d524c1 and 3a76919.

📒 Files selected for processing (4)
  • 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/services/ce/ConsolidatedAPIServiceCEImpl.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/git/CommonGitServiceCETest.java (1 hunks)
  • app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java (4 hunks)
🧰 Additional context used
📓 Learnings (2)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java (2)
Learnt from: sumitsum
PR: appsmithorg/appsmith#29875
File: app/server/appsmith-server/src/main/java/com/appsmith/server/services/ConsolidatedAPIServiceImpl.java:0-0
Timestamp: 2024-11-12T08:11:25.416Z
Learning: Test cases for the `getConsolidatedInfoForPageLoad` method have already been added, and the refactoring of the method into smaller methods is planned for later and is being tracked in a separate GitHub issue.
Learnt from: sumitsum
PR: appsmithorg/appsmith#29875
File: app/server/appsmith-server/src/main/java/com/appsmith/server/services/ConsolidatedAPIServiceImpl.java:0-0
Timestamp: 2024-11-12T08:11:25.417Z
Learning: Test cases for the `getConsolidatedInfoForPageLoad` method have already been added, and the refactoring of the method into smaller methods is planned for later and is being tracked in a separate GitHub issue.
app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java (2)
Learnt from: sumitsum
PR: appsmithorg/appsmith#29875
File: app/server/appsmith-server/src/main/java/com/appsmith/server/services/ConsolidatedAPIServiceImpl.java:0-0
Timestamp: 2024-11-12T08:11:25.416Z
Learning: Test cases for the `getConsolidatedInfoForPageLoad` method have already been added, and the refactoring of the method into smaller methods is planned for later and is being tracked in a separate GitHub issue.
Learnt from: sumitsum
PR: appsmithorg/appsmith#29875
File: app/server/appsmith-server/src/main/java/com/appsmith/server/services/ConsolidatedAPIServiceImpl.java:0-0
Timestamp: 2024-11-12T08:11:25.417Z
Learning: Test cases for the `getConsolidatedInfoForPageLoad` method have already been added, and the refactoring of the method into smaller methods is planned for later and is being tracked in a separate GitHub issue.
🔇 Additional comments (3)
app/server/appsmith-server/src/main/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceCEImpl.java (1)

303-331: Logic for handling Git-connected applications and branches is well-implemented

The updated code correctly manages scenarios where the application is Git-connected and the branch name is either provided or absent. The conditions ensure that the appropriate application and page are retrieved based on the Git metadata and the view mode.

app/server/appsmith-server/src/test/java/com/appsmith/server/services/ce/ConsolidatedAPIServiceImplTest.java (1)

1425-1619: Tests added correctly for edge case handling

The new test method effectively covers the scenario when the page is from a feature branch and the cacheable repository returns the base application ID.

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

1490-1492: Code implementation looks good

The importArtifactInWorkspaceFromGit method is called correctly.

Comment on lines +1493 to +1498
.flatMap(importedArtifact -> gitArtifactHelper.publishArtifact(importedArtifact, false))
.flatMap(publishedArtifact -> addAnalyticsForGitOperation(
AnalyticsEvents.GIT_CHECKOUT_REMOTE_BRANCH,
publishedArtifact,
Boolean.TRUE.equals(
publishedArtifact.getGitArtifactMetadata().getIsRepoPrivate())))
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Ensure error handling in reactive chain

Consider adding error handling to manage exceptions from publishArtifact and addAnalyticsForGitOperation to prevent potential unhandled errors.

Comment on lines +1870 to +1874
return gitArtifactHelper
.publishArtifact(importedBranchedArtifact, false)
.then(commitArtifact(
commitDTO, baseArtifact, importedBranchedArtifact, false, false)
.thenReturn(gitPullDTO));
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Handle exceptions in reactive calls

Ensure that any errors from publishArtifact and commitArtifact are properly handled and propagated to avoid silent failures.

@sondermanish sondermanish enabled auto-merge (squash) November 15, 2024 09:26
@sondermanish sondermanish merged commit 6883e49 into release Nov 15, 2024
48 checks passed
@sondermanish sondermanish deleted the fix/binding-and-consolidated-api branch November 15, 2024 09:27
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
…ithorg#37399)

## Description

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.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/11851164290>
> Commit: 3a76919
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=11851164290&attempt=2"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git`
> Spec:
> <hr>Fri, 15 Nov 2024 07:01:40 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**
- Enhanced handling of Git operations, including improved branch
management and artifact importation.
- Expanded analytics integration for tracking changes in branch
protection settings.

- **Bug Fixes**
- Improved error handling for various Git operations and
application/page retrieval scenarios.

- **Tests**
- Added new test cases for Git-related functionalities and improved
error handling in tests.
- Enhanced test coverage for the `getConsolidatedInfoForPageLoad`
method, particularly for feature branches.

<!-- 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
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants