Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,12 @@ public Mono<TriggerResultDTO> trigger(

// If the plugin has overridden and implemented the same, use the plugin result
Mono<TriggerResultDTO> resultFromPluginMono = Mono.zip(
validatedDatasourceStorageMono, pluginMono, pluginExecutorMono)
validatedDatasourceStorageMono, pluginMono, pluginExecutorMono, datasourceMonoCached)
.flatMap(tuple -> {
final DatasourceStorage datasourceStorage = tuple.getT1();
final Plugin plugin = tuple.getT2();
final PluginExecutor pluginExecutor = tuple.getT3();
final Datasource datasource = tuple.getT4();

// TODO: Flags are needed here for google sheets integration to support shared drive behind a flag
// Once thoroughly tested, this flag can be removed
Expand All @@ -118,7 +119,7 @@ public Mono<TriggerResultDTO> trigger(
// Now that we have the context (connection details), execute the action.
// datasource remains unevaluated for datasource of DBAuth Type Authentication,
// However the context comes from evaluated datasource.
.flatMap(resourceContext -> setTenantAndInstanceId(triggerRequestDTO)
.flatMap(resourceContext -> populateTriggerRequestDto(triggerRequestDTO, datasource)
.flatMap(updatedTriggerRequestDTO -> ((PluginExecutor<Object>) pluginExecutor)
.triggerWithFlags(
resourceContext.getConnection(),
Expand Down Expand Up @@ -161,13 +162,14 @@ public Mono<TriggerResultDTO> trigger(
return resultFromPluginMono.switchIfEmpty(defaultResultMono);
}

private Mono<TriggerRequestDTO> setTenantAndInstanceId(TriggerRequestDTO triggerRequestDTO) {
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
Copy Markdown
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.

}
Expand Down