Skip to content

chore: set workspaceId to triggerRequestDto#38244

Merged
nsarupr merged 3 commits intoreleasefrom
chore/set-workspaceId-to-triggerRequestDto
Dec 20, 2024
Merged

chore: set workspaceId to triggerRequestDto#38244
nsarupr merged 3 commits intoreleasefrom
chore/set-workspaceId-to-triggerRequestDto

Conversation

@nsarupr
Copy link
Contributor

@nsarupr nsarupr commented Dec 18, 2024

Description

Set workspace ID to the TriggerRequestDTO.

Fixes #Issue Number
or
Fixes Issue URL

Warning

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

Automation

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

🔍 Cypress test results

Tip

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


Fri, 20 Dec 2024 06:38:48 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Enhanced trigger functionality to directly access and utilize the Datasource object.
    • Updated method to incorporate workspace ID in trigger requests.
  • Bug Fixes

    • Improved error handling for null requestType or parameters in trigger requests.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 18, 2024

Walkthrough

The pull request modifies the DatasourceTriggerSolutionCEImpl class in the Appsmith server, focusing on enhancing the trigger method and introducing a new populateTriggerRequestDto method. The changes improve how datasource context is handled by adding a cached datasource parameter and enabling more flexible workspace ID population within trigger request processing.

Changes

File Change Summary
app/server/appsmith-server/src/main/java/.../DatasourceTriggerSolutionCEImpl.java - Renamed setTenantAndInstanceId to populateTriggerRequestDto
- Updated method signature to accept Datasource parameter
- Modified trigger method to include datasourceMonoCached in Mono.zip

Possibly related PRs

  • feat: pass workspace id to form control #37413: This PR adds a workspaceId property to the ControlData interface and updates the FormControl component to utilize this new property, which is related to the changes in the populateTriggerRequestDto method that also incorporates workspace context.

Suggested labels

Enhancement

Suggested reviewers

  • sharat87
  • abhvsn
  • AnaghHegde

Poem

🌟 Datasource dancing, context unfurled
Code pirouettes through a monadic world
Triggers spin with workspace in hand
Refactoring magic across the land! 🎉
Smooth as silk, robust and bright


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b2b35a4 and b24c511.

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

104-109: LGTM: Clean integration of datasource parameter

The addition of datasourceMonoCached to Mono.zip and its subsequent usage in the flatMap chain is well-structured and maintains reactive programming patterns.

Also applies to: 122-122


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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

Documentation and Community

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

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 836b544 and b2b35a4.

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

104-109: LGTM! Verify reactive chain completion.

The addition of datasource to the zip operation and its usage in the chain is correct. The reactive flow is properly maintained.

Let's verify that all reactive chains are properly completed:

Also applies to: 122-122

✅ Verification successful

LGTM! Reactive chain is properly structured and complete.

The reactive chain in the trigger method is well-constructed with proper error handling and chain completion:

  • Zip operation correctly combines all required Mono streams
  • FlatMap operations maintain the reactive flow
  • Cache operators are used appropriately for shared streams
  • Error cases are handled with Mono.error()
  • Chain terminates with proper transformations via map/flatMap
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any incomplete reactive chains (missing subscribe/block)
ast-grep --pattern 'Mono.$_().flatMap($_)' 

Length of output: 44


Script:

#!/bin/bash
# Let's search for the trigger method implementation to verify reactive chain completion
ast-grep --pattern 'public Mono<DatasourceTestResult> trigger($$$)'

# Also search for any subscribe/block calls in the class
rg -A 2 "\.(subscribe|block)\(" 

Length of output: 114704


Script:

#!/bin/bash
# Let's search for the trigger method implementation to verify the reactive chain completion
rg -A 10 "public\s+Mono<DatasourceTestResult>\s+trigger" 

# Also search for any return statements in the trigger method
rg -A 2 "return\s+Mono\." app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/DatasourceTriggerSolutionCEImpl.java

Length of output: 424


Script:

#!/bin/bash
# Let's search for the trigger method implementation with more context
rg -B 5 -A 20 "public\s+Mono<DatasourceTestResult>\s+trigger" app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/DatasourceTriggerSolutionCEImpl.java

# Also search for any zip operations in the trigger method
rg -A 5 "Mono\.zip\(" app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/DatasourceTriggerSolutionCEImpl.java

Length of output: 728


Script:

#!/bin/bash
# Let's get the full trigger method implementation to verify the reactive chain
ast-grep --pattern 'public Mono<DatasourceTestResult> trigger($$$) {
  $$$
}' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/DatasourceTriggerSolutionCEImpl.java

# Also search for any map/flatMap operations after the zip
rg -A 10 "\.flatMap\(" app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/DatasourceTriggerSolutionCEImpl.java

Length of output: 4191

Comment on lines 165 to 174
private Mono<TriggerRequestDTO> populateTriggerRequestDto(TriggerRequestDTO triggerRequestDTO, Datasource datasource) {
return tenantService
.getDefaultTenantId()
.zipWith(configService.getInstanceId())
.map(tuple -> {
triggerRequestDTO.setTenantId(tuple.getT1());
triggerRequestDTO.setInstanceId(tuple.getT2());
triggerRequestDTO.setWorkspaceId(datasource.getWorkspaceId());
return triggerRequestDTO;
});
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

Add null check for datasource parameter.

While the method implementation is correct, consider adding a null check for the datasource parameter to prevent NullPointerException.

 private Mono<TriggerRequestDTO> populateTriggerRequestDto(TriggerRequestDTO triggerRequestDTO, Datasource datasource) {
+    if (datasource == null) {
+        return Mono.error(new AppsmithException(AppsmithError.INVALID_PARAMETER, "datasource"));
+    }
     return tenantService

Committable suggestion skipped: line range outside the PR's diff.

@github-actions
Copy link

Failed server tests

  • com.appsmith.server.git.ServerSchemaMigrationEnforcerTest#saveGitRepo_ImportAndThenExport_diffOccurs

@nsarupr nsarupr self-assigned this Dec 19, 2024
@nsarupr nsarupr added the ok-to-test Required label for CI label Dec 19, 2024
@nsarupr nsarupr changed the title set workspaceId to triggerRequestDto chore: set workspaceId to triggerRequestDto Dec 19, 2024
@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Dec 19, 2024
@nsarupr nsarupr requested a review from trishaanand December 19, 2024 08:35
@nsarupr nsarupr merged commit 3ff89d7 into release Dec 20, 2024
@nsarupr nsarupr deleted the chore/set-workspaceId-to-triggerRequestDto branch December 20, 2024 12:09
NandanAnantharamu pushed a commit that referenced this pull request Dec 27, 2024
## Description
> Set workspace ID to the TriggerRequestDTO.

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

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12426442788>
> Commit: 8a4bd2e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12426442788&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Fri, 20 Dec 2024 06:38:48 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Enhanced trigger functionality to directly access and utilize the
`Datasource` object.
	- Updated method to incorporate workspace ID in trigger requests.

- **Bug Fixes**
- Improved error handling for null `requestType` or `parameters` in
trigger requests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

Co-authored-by: Nilesh Sarupriya <20905988+nsarupr@users.noreply.github.com>
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Feb 7, 2025
## Description
> Set workspace ID to the TriggerRequestDTO.

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

## Automation

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

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!TIP]
> 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
> Workflow run:
<https://github.com/appsmithorg/appsmith/actions/runs/12426442788>
> Commit: 8a4bd2e
> <a
href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12426442788&attempt=1"
target="_blank">Cypress dashboard</a>.
> Tags: `@tag.Sanity`
> Spec:
> <hr>Fri, 20 Dec 2024 06:38:48 UTC
<!-- end of auto-generated comment: Cypress test results  -->


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


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

## Summary by CodeRabbit

- **New Features**
- Enhanced trigger functionality to directly access and utilize the
`Datasource` object.
	- Updated method to incorporate workspace ID in trigger requests.

- **Bug Fixes**
- Improved error handling for null `requestType` or `parameters` in
trigger requests.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

---------

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

Labels

ok-to-test Required label for CI 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