8000 fix: Avoid having mismatched data in Plugin Action form by hetunandu · Pull Request #40264 · appsmithorg/appsmith · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Avoid having mismatched data in Plugin Action form #40264

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 1 commit into from
Apr 17, 2025

Conversation

hetunandu
Copy link
Member
@hetunandu hetunandu commented Apr 16, 2025

Description

It was seen that when switching between actions, the form data and the action data is not in sync through all the render cycles. This causes the old form data to be rendered using the new (switched to) editor config.

By verifying this and handling the render, we are ensuring that during switches, the form data is accurate while rendering

Fixes #40183

Automation

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

🔍 Cypress test results

Tip

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


Wed, 16 Apr 2025 05:56:10 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of form data loading states to prevent the form from rendering when data is unavailable, reducing the risk of errors or displaying stale information.

Copy link
Contributor
coderabbitai bot commented Apr 16, 2025

Walkthrough

A guard clause was introduced in the UQIEditorForm component to prevent rendering when form data is unavailable. The useFormData hook was updated to integrate context from usePluginActionContext, ensuring that it returns null data and an empty evaluation state if the current form data does not correspond to the active action. Variable naming was clarified, and logic was added to avoid returning stale form data during action switches. No changes were made to the exported hook's signature.

Changes

File(s) Change Summary
.../UQIEditorForm.tsx Added a null check for form data; component returns null if data is unavailable.
.../hooks/useFormData.ts Integrated action context, improved form data selection logic, renamed variables for clarity, handled stale data.

Sequence Diagram(s)

sequenceDiagram
    participant UI as UQIEditorForm
    participant Hook as useFormData
    participant Ctx as usePluginActionContext

    UI->>Hook: Call useFormData()
    Hook->>Ctx: Get current action
    Hook->>Hook: Select form data for action.id
    alt Form data missing or mismatched
        Hook->>UI: Return { data: null, evaluationState: {} }
        UI->>UI: Return null (do not render)
    else Form data valid
        Hook->>UI: Return { data, evaluationState }
        UI->>UI: Render form
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent random error toasts due to stale or mismatched form data (#40183)

Suggested labels

Integrations Product, Integrations Pod

Poem

When queries switch and actions change,
No more errors, nothing strange!
With null guards set and context clear,
The toasts of doom no longer appear.
Code now guards what forms can show,
Smooth integrations, onward we go! 🚀


📜 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 de7f73d and 195a03e.

📒 Files selected for processing (2)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx (1 hunks)
  • app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useFormData.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useFormData.ts (2)
app/client/src/entities/Action/index.ts (2)
  • QueryAction (217-222)
  • SaaSAction (178-184)
app/client/src/selectors/formSelectors.ts (1)
  • getFormEvaluationState (42-43)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (7)
app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/hooks/useFormData.ts (6)

6-6: Good addition of the action context hook.

Adding the plugin action context allows accessing the current action, essential for validating that form data matches the active action.


9-11: Good variable renaming for clarity.

Renaming from data to formData improves readability while preserving the type casting.


13-14: Appropriate action extraction from context.

Extracting the current action from context is essential for the form data validation logic.


16-20: Excellent fix for handling action switching.

This conditional check effectively prevents stale data from being displayed during action switches. By comparing form data ID with action ID and returning null when they don't match, you ensure synchronization between the form and action context.


23-23: Clean and direct evaluation state access.

Directly accessing the evaluation state with the form data ID is more concise.


25-25: Maintained consistent return interface.

The return structure preserves the hook's interface while using more descriptive internal variables.

app/client/src/PluginActionEditor/components/PluginActionForm/components/UQIEditor/UQIEditorForm.tsx (1)

21-23: Effective guard clause to prevent rendering with invalid data.

This null check prevents the component from rendering when no valid data is available. It works in conjunction with the useFormData hook changes to ensure the UI only displays when form data is synchronized with the current action.

✨ 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.
    • 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 generate docstrings to generate docstrings for 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.
8000

@hetunandu hetunandu added the ok-to-test Required label for CI label Apr 16, 2025
@github-actions github-actions bot added AI Agents Issues related to agentic solutions on Appsmith Anvil Pod Issue related to Anvil project Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage Release labels Apr 16, 2025
@hetunandu hetunandu merged commit b37155e into release Apr 17, 2025
49 checks passed
@hetunandu hetunandu deleted the fix/PAE/form-data-mismatch branch April 17, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Agents Issues related to agentic solutions on Appsmith Anvil Pod Issue related to Anvil project Bug Something isn't working High This issue blocks a user from building or impacts a lot of users Needs Triaging Needs attention from maintainers to triage ok-to-test Required label for CI Release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Random error toasts on running a query
2 participants
0