Skip to content

fix: enhance null handling in action parameter evaluation and rendering #40910

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

Merged
merged 2 commits into from
Jun 11, 2025

Conversation

nsarupr
Copy link
Contributor

@nsarupr nsarupr commented Jun 10, 2025

Description

This update improves the handling of null values in action parameter evaluation and rendering processes. Specifically, it ensures that null values are treated appropriately, preventing unnecessary stringification and Blob creation. This change enhances the robustness of the action execution flow and prevents potential errors related to null values.

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

🔍 Cypress test results

Tip

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


Tue, 10 Jun 2025 10:21:02 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of null and empty parameter values during action execution, ensuring that nulls are preserved and not incorrectly converted to strings or empty values.
    • Enhanced template rendering to better preserve original formatting when bindings are missing.
  • New Features
    • Added new logic to sanitize null parameter values before action execution for more consistent processing.

…evaluation and rendering processes. Specifically, it ensures that null values are treated appropriately, preventing unnecessary stringification and Blob creation. This change enhances the robustness of the action execution flow and prevents potential errors related to null values.
Copy link
Contributor

coderabbitai bot commented Jun 10, 2025

Walkthrough

These changes refine the handling of null and empty parameter values across both frontend and backend layers. The updates ensure that null values are preserved or sanitized consistently during action execution, parameter evaluation, variable substitution, and mustache rendering, with logic moved or adjusted for more accurate and predictable processing.

Changes

File(s) Change Summary
app/client/src/sagas/ActionExecution/PluginActionSaga.ts Modified parameter evaluation to treat null distinctly, avoiding stringification or Blob-wrapping of null values.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java Changed mustache rendering to use full token as key and preserve original token if key is missing in the map.
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java Added sanitiseNullsInParams method; updated variable substitution to handle nulls and duplicate keys explicitly.
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java Moved null/empty string handling to parameter parsing; removed post-processing null replacement.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant PluginActionSaga
    participant Server
    participant PluginExecutor
    participant MustacheHelper

    Client->>PluginActionSaga: Trigger action with parameters (may include nulls)
    PluginActionSaga->>PluginActionSaga: Evaluate parameters (preserve nulls)
    PluginActionSaga->>Server: Send evaluated parameters
    Server->>PluginExecutor: Execute action (sanitise nulls)
    PluginExecutor->>MustacheHelper: Render mustache tokens (preserve formatting if missing)
    MustacheHelper-->>PluginExecutor: Return rendered result
    PluginExecutor-->>Server: Return execution result
    Server-->>Client: Respond with action result
Loading

Poem

In code we trust, and nulls we tame,
No stringified ghosts, no blobs of shame.
Mustache tokens hold their ground,
If values are missing, they're left as found.
With parameters parsed and logic neat,
Our data's journey is now complete!
🎉


📜 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 b5435c5 and b869dfa.

📒 Files selected for processing (1)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: server-unit-tests / server-unit-tests
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

@github-actions github-actions bot added the Bug Something isn't working label Jun 10, 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: 1

🧹 Nitpick comments (1)
app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java (1)

316-326: Clarify the purpose of converting nulls to "null" strings.

This method converts null parameter values to the string "null", which seems counterintuitive given the PR's goal of enhancing null handling. Consider adding documentation explaining when and why this conversion is necessary for plugin compatibility.

+    /**
+     * Sanitizes null parameter values by converting them to string "null".
+     * This is required for plugin compatibility where null values cannot be processed.
+     */
     default void sanitiseNullsInParams(ExecuteActionDTO executeActionDTO) {
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between befe9ff and b5435c5.

📒 Files selected for processing (4)
  • app/client/src/sagas/ActionExecution/PluginActionSaga.ts (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java (1 hunks)
  • app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java (3 hunks)
  • app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java (3 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: server-unit-tests / server-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: server-spotless / spotless-check
  • GitHub Check: client-lint / client-lint
🔇 Additional comments (7)
app/client/src/sagas/ActionExecution/PluginActionSaga.ts (2)

492-499: LGTM - Proper null preservation in JSON serialization

The explicit null check prevents JSON.stringify(null) from converting null to the string "null", correctly preserving the null value in the evaluated parameters.


505-510: LGTM - Consistent null handling for Blob creation

Good addition to prevent creating a Blob with "null" content when the value is actually null. This maintains consistency with the null handling approach in the previous segment.

app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java (2)

66-66: Required import for new FormFieldPart usage

The import is necessary for the type checking in the parseExecuteParameter method.


345-346: Clear documentation of the architectural change

Good practice to document the removal of the previous null handling approach.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/helpers/MustacheHelper.java (1)

344-354: LGTM! Improved null handling in mustache token rendering.

The logic correctly preserves original token formatting when keys are missing and only replaces tokens with non-null binding values. This prevents unnecessary conversion of null values to strings during template rendering.

app/server/appsmith-interfaces/src/main/java/com/appsmith/external/plugins/PluginExecutor.java (2)

308-308: Addition of null sanitization call looks appropriate.

The call to sanitiseNullsInParams is placed at the right entry point to ensure consistent parameter handling before execution.


393-407: Improved null preservation in variable substitution.

The refactored logic correctly preserves null values instead of converting them to strings, and the explicit loop with putIfAbsent properly handles duplicate keys. This aligns well with the PR's null handling improvements.

Comment on lines +509 to +518

if (part instanceof FormFieldPart) {
FormFieldPart formFieldPart = (FormFieldPart) part;
if ("null".equals(formFieldPart.value())) {
param.setValue(null);
} else if (formFieldPart.value().isEmpty()) {
param.setValue(formFieldPart.value());
}
return Mono.just(param);
}
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

Verify string literal comparison and consider edge cases

The logic correctly handles null and empty string cases for FormFieldPart, but consider these potential improvements:

  1. The string comparison "null".equals(formFieldPart.value()) could be more robust
  2. Missing else clause means the value remains unset for non-empty, non-null cases

Consider this more explicit implementation:

 if (part instanceof FormFieldPart) {
     FormFieldPart formFieldPart = (FormFieldPart) part;
-    if ("null".equals(formFieldPart.value())) {
+    String value = formFieldPart.value();
+    if ("null".equals(value)) {
         param.setValue(null);
-    } else if (formFieldPart.value().isEmpty()) {
-        param.setValue(formFieldPart.value());
+    } else if (value.isEmpty()) {
+        param.setValue("");
+    } else {
+        param.setValue(value);
     }
     return Mono.just(param);
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (part instanceof FormFieldPart) {
FormFieldPart formFieldPart = (FormFieldPart) part;
if ("null".equals(formFieldPart.value())) {
param.setValue(null);
} else if (formFieldPart.value().isEmpty()) {
param.setValue(formFieldPart.value());
}
return Mono.just(param);
}
if (part instanceof FormFieldPart) {
FormFieldPart formFieldPart = (FormFieldPart) part;
String value = formFieldPart.value();
if ("null".equals(value)) {
param.setValue(null);
} else if (value.isEmpty()) {
param.setValue("");
} else {
param.setValue(value);
}
return Mono.just(param);
}
🤖 Prompt for AI Agents
In
app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/ActionExecutionSolutionCEImpl.java
around lines 509 to 518, the current code compares the string literal "null" to
formFieldPart.value() which may not be robust and lacks handling for non-empty,
non-"null" values. Update the comparison to safely handle null values and add an
else clause to set param's value for all other cases, ensuring param.setValue is
always called appropriately.

Copy link

Failed server tests

  • com.external.plugins.AmazonS3PluginTest#
  • com.external.utils.AmazonS3ErrorUtilsTest#
  • com.external.plugins.ChatCommandTest#
  • com.external.plugins.AnthropicPluginTest#
  • com.external.plugins.services.HeadersUtilTest#
  • com.external.plugins.services.AiFeatureServiceFactoryTest#
  • com.external.plugins.services.FileUtilTest#
  • com.external.plugins.services.FieldValidationHelperTest#
  • com.external.plugins.services.features.TextEntityExtractionServiceImplTest#
  • com.external.plugins.services.features.TextClassificationServiceImplTest#
  • com.external.plugins.services.features.ImageClassificationServiceImplTest#
  • com.external.plugins.services.features.TextGenerationServiceImplTest#
  • com.external.plugins.services.features.ImageCaptioningServiceImplTest#
  • com.external.plugins.services.features.TextSummarizationServiceImplTest#
  • com.external.plugins.services.features.ImageEntityExtractionServiceImplTest#
  • com.external.plugins.ArangoDBPluginTest#
  • com.external.plugins.AwsLambdaPluginTest#
  • com.external.plugins.DatabricksPluginTest#
  • com.external.plugins.DynamoPluginTest#
  • com.external.plugins.ElasticSearchPluginTest#
  • com.external.plugins.FirestorePluginTest#
  • com.external.plugins.GoogleAiPluginTest#
  • com.external.plugins.GenerateContentCommandTest#
  • com.external.config.RowsUpdateMethodTest#
  • com.external.config.FileListMethodTest#
  • com.external.config.RowsGetMethodTest#
  • com.external.config.MethodConfigTest#
  • com.external.config.GetStructureMethodTest#
  • com.external.config.RowsAppendMethodTest#
  • com.external.config.RowsBulkUpdateMethodTest#
  • com.external.config.FileInfoMethodTest#
  • com.external.config.SheetsUtilTest#
  • com.external.config.RowsBulkAppendMethodTest#
  • com.external.config.GetDatasourceMetadataMethodTest#
  • com.external.plugins.GraphQLPluginTest#
  • com.external.plugins.MongoPluginRegexTest#
  • com.external.plugins.MongoPluginErrorsTest#
  • com.external.plugins.MongoPluginStaleConnTest#
  • com.external.plugins.utils.DatasourceUtilsTest#
  • com.external.plugins.utils.MongoPluginUtilsTest#
  • com.external.plugins.MongoPluginDataTypeTest#
  • com.external.plugins.MongoPluginDatasourceTest#
  • com.external.plugins.MongoPluginQueriesTest#
  • com.external.plugins.MongoPluginFormsTest#
  • com.external.plugins.MssqlPluginTest#
  • com.external.plugins.MssqlGetDBSchemaTest#
  • com.external.plugins.MySqlStaleConnectionErrorMessageTest#
  • com.external.plugins.MySQLPluginDataTypeTest#
  • com.external.plugins.MySqlPluginTest#
  • com.external.plugins.MySQLDatasourceValidationTest#
  • com.external.utils.QueryUtilsTest#
  • com.external.plugins.EmbeddingCommandTest#
  • com.external.plugins.OpenAIPluginTest#
  • com.external.plugins.VisionCommandTest#
  • com.external.plugins.OracleExecutionTest#
  • com.external.plugins.OracleGetDBSchemaTest#
  • com.external.plugins.OraclePluginDatasourceValidityErrorsTest#
  • com.external.plugins.OraclePluginErrorsTest#
  • com.external.plugins.OraclePluginConnectionTest#
  • com.external.plugins.OracleConnectionRateLimitTest#
  • com.external.plugins.PostgresPluginTest#
  • com.external.plugins.PostgresPluginDataTypeTest#
  • com.external.plugins.PostgresDatasourceValidationTest#
  • com.external.plugins.RedisPluginTest#
  • com.external.plugins.RedshiftPluginTest#
  • com.external.plugins.RestApiPluginTest#
  • com.external.plugins.SmtpPluginTest#
  • com.external.plugins.SnowflakePluginTest#
  • com.appsmith.git.converters.GsonDoubleToLongConverterTest#
  • com.appsmith.git.helpers.DSLTransformerHelperTest#
  • com.appsmith.git.helpers.FileUtilsImplTest#
  • GsonUnorderedToOrderedSerializationTest#
  • com.appsmith.external.helpers.MustacheHelperTest#allActionConfigurationFields
  • com.appsmith.external.helpers.MustacheHelperTest#allDatasourceConfigurationFields
  • com.appsmith.external.helpers.MustacheHelperTest#bodyInMustaches
  • com.appsmith.external.helpers.MustacheHelperTest#bodyWithNewlineInMustaches
  • com.appsmith.external.helpers.MustacheHelperTest#renderBodyWithMultilineJavascriptInMustaches
  • com.appsmith.external.helpers.MustacheHelperTest#renderMultipleKeys
  • com.appsmith.external.helpers.MustacheHelperTest#renderMultipleKeysWithSpaces
  • com.appsmith.external.helpers.MustacheHelperTest#renderMustacheComment
  • com.appsmith.external.helpers.MustacheHelperTest#renderMustacheCondition
  • com.appsmith.external.helpers.MustacheHelperTest#renderMustacheSubSection
  • com.appsmith.external.helpers.MustacheHelperTest#renderSingleKey
  • com.appsmith.external.helpers.MustacheHelperTest#renderSingleKeyWithLeading
  • com.appsmith.external.helpers.MustacheHelperTest#renderSingleKeyWithLeadingAndTailing
  • com.appsmith.external.helpers.MustacheHelperTest#renderSingleKeyWithTailing
  • com.appsmith.external.helpers.MustacheHelperTest#render_WhenValueContainsHtmlDoubleQuotes_ReturnsEscapedCharacter
  • com.appsmith.external.helpers.MustacheHelperTest#render_WhenValueContainsHtmlReservedCharacters_ReturnsEscapedCharacters
  • com.appsmith.external.helpers.MustacheHelperTest#whenBindingFoundWithoutValue_doNotReplaceWithNull

…ming the surrounding braces. This change enhances the clarity of the token processing logic, ensuring that the rendered output accurately reflects the intended values without leading or trailing whitespace.
@nsarupr nsarupr added the ok-to-test Required label for CI label Jun 10, 2025
@nsarupr nsarupr requested a review from nidhi-nair June 10, 2025 09:13
@nsarupr nsarupr merged commit 5d5f7ae into release Jun 11, 2025
92 checks passed
@nsarupr nsarupr deleted the chore/handle-nulls-in-query-params branch June 11, 2025 14:53
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