Skip to content

fix: fix validation for datasource in action import and save flow#34754

Merged
AnaghHegde merged 2 commits intoreleasefrom
fix/datasource-validation-error
Jul 8, 2024
Merged

fix: fix validation for datasource in action import and save flow#34754
AnaghHegde merged 2 commits intoreleasefrom
fix/datasource-validation-error

Conversation

@AnaghHegde
Copy link
Contributor

@AnaghHegde AnaghHegde commented Jul 5, 2024

Description

More details here - https://theappsmith.slack.com/archives/CTHN8GX5Y/p1720156198256419

Automation

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

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/9809585760
Commit: 72dc336
Cypress dashboard.
Tags: @tag.Git, @tag.Templates, @tag.ImportExport


Fri, 05 Jul 2024 14:30:53 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features
    • Enhanced validation process for actions with the introduction of a Dry Operations mode, allowing for validation without persistence.

@AnaghHegde AnaghHegde self-assigned this Jul 5, 2024
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 5, 2024

Walkthrough

The changes enhance the NewActionServiceCEImpl class by extending the validateAction method to accept a boolean parameter, isDryOps. This new parameter dictates how the action's validity and error handling are managed. Consequently, method calls within the class are updated to pass this new flag as an argument. Additionally, there is a minor update in the NewActionImportableServiceCEImpl class to set the workspaceId of a newAction based on its datasource.

Changes

Files Change Summaries
.../base/NewActionServiceCE.java Added isDryOps parameter to validateAction method in NewActionServiceCE interface.
.../base/NewActionServiceCEImpl.java Updated validateAction method to include isDryOps parameter. Modified method calls to accommodate the new parameter.
.../importable/NewActionImportableServiceCEImpl.java Added a line to set workspaceId of newAction based on its datasource.

Poem

In code's deep sea, a dry run sails,
New flags to guide, like flowing tails.
Actions check with newfound might,
Through dry or wet, they're tested right.
A workspace set, connections tight,
Onward, upward, code's pure delight!


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.

@AnaghHegde
Copy link
Contributor Author

/build-deploy-preview -skip-tests=true

@github-actions github-actions bot added the Bug Something isn't working label Jul 5, 2024
@github-actions
Copy link

github-actions bot commented Jul 5, 2024

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

@AnaghHegde AnaghHegde added ok-to-test Required label for CI and removed Bug Something isn't working labels Jul 5, 2024
@github-actions github-actions bot added the Bug Something isn't working label Jul 5, 2024
@rahulbarwal
Copy link
Contributor

@AnaghHegde Please run import export and templates tag in ok-to-test.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Outside diff range and nitpick comments (1)
app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java (1)

[!TIP]
Codebase Verification

Update test case to use the new method signature

The test case in RefactoringServiceCETest.java has not been updated to use the new validateAction method signature with the isDryOps parameter. Please update the test case to ensure it correctly uses the new method signature.

  • app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java at line 578
Analysis chain

Line range hint 293-386: LGTM! But verify the method usage in the codebase.

The addition of the new validateAction method with the isDryOps parameter is consistent with the interface's purpose. The isDryOps parameter is used to control the validation behavior, particularly in handling the absence of a datasource.

However, ensure that all invocations of this method are updated accordingly.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all invocations of the new validateAction method with the isDryOps parameter.

# Test: Search for the method usage. Expect: Only occurances of the new method signature.
rg --type java $'validateAction'

Length of output: 2285


Script:

#!/bin/bash
# Description: List lines of code where validateAction is called without the isDryOps parameter to ensure all instances are updated.

# Search for validateAction invocations without the isDryOps parameter.
rg --type java 'validateAction\([^,]*\)' -n

Length of output: 699


Script:

#!/bin/bash
# Description: Check the `RefactoringServiceCETest.java` file to verify if the test case is correctly updated to use the new method signature.

# Display the relevant lines around the invocation in RefactoringServiceCETest.java
rg --type java 'validateAction' -A 5 -B 5 app/server/appsmith-server/src/test/java/com/appsmith/server/refactors/ce/RefactoringServiceCETest.java

Length of output: 749

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3771508 and 389c15a.

Files selected for processing (3)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java (1 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/importable/NewActionImportableServiceCEImpl.java
Additional comments not posted (4)
app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCE.java (1)

42-43: LGTM! But verify the method usage in the codebase.

The addition of the new validateAction method with the isDryOps parameter is consistent with the interface's purpose.

However, ensure that all implementations and invocations of this method are updated accordingly.

app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java (3)

290-291: LGTM!

The method validateAction has been updated to include the isDryOps parameter with a default value of false.


451-453: LGTM!

The method bulkValidateAndInsertActionInRepository has been updated to call validateAction(newAction, true), setting the isDryOps parameter to true for bulk validation and insertion.


459-461: LGTM!

The method bulkValidateAndUpdateActionInRepository has been updated to call validateAction(newAction, true), setting the isDryOps parameter to true for bulk validation and update.

@github-actions
Copy link

github-actions bot commented Jul 5, 2024

Failed server tests

  • com.appsmith.server.exports.internal.ExportServiceTests#createExportAppJsonForGitTest

invalids.add(AppsmithError.NO_RESOURCE_FOUND.getMessage(
FieldName.DATASOURCE,
action.getDatasource().getId()));
if (!isDryOps) {
Copy link
Contributor

Choose a reason for hiding this comment

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

When would this validation happen in case of dryOps?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

When the datasource is attached to action, we fetch datasource from db and update the workspaceId for action.

@AnaghHegde AnaghHegde added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 5, 2024
@AnaghHegde AnaghHegde requested a review from sondermanish July 5, 2024 14:08
@AnaghHegde AnaghHegde added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jul 5, 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 389c15a and 72dc336.

Files selected for processing (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java (3 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/newactions/base/NewActionServiceCEImpl.java

@AnaghHegde AnaghHegde requested a review from nidhi-nair July 7, 2024 18:33
@sondermanish
Copy link
Contributor

Approved with deferred tackling of updateDatasourcePolicyForPublicAction

@AnaghHegde AnaghHegde merged commit f03b6b0 into release Jul 8, 2024
@AnaghHegde AnaghHegde deleted the fix/datasource-validation-error branch July 8, 2024 04:31
Shivam-z pushed a commit to Shivam-z/appsmith that referenced this pull request Jul 10, 2024
…psmithorg#34754)

## Description
More details here -
https://theappsmith.slack.com/archives/CTHN8GX5Y/p1720156198256419

## Automation

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

### 🔍 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/9809585760>
> Commit: 72dc336
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=9809585760&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Git, @tag.Templates, @tag.ImportExport`
> <hr>Fri, 05 Jul 2024 14:30:53 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 validation process for actions with the introduction of a
`Dry Operations` mode, allowing for validation without persistence.
<!-- 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.

4 participants