Skip to content

Conversation

@ChmaraX
Copy link
Contributor

@ChmaraX ChmaraX commented Dec 4, 2025

What changed? Why was the change needed?

Screenshots

Expand for optional sections

Related enterprise PR

Special notes for your reviewer

Summary by CodeRabbit

Release Notes

  • New Features

    • Added contextual error messages for invalid variables, providing clearer feedback on validation issues such as missing schemas or invalid namespace configurations.
  • Improvements

    • Streamlined variable insertion workflow for improved usability.
    • Enhanced validation logic to better identify problematic variable configurations.
    • Implemented consistent error messaging across all editor components.

✏️ Tip: You can customize this high-level summary in your review settings.

@linear
Copy link

linear bot commented Dec 4, 2025

@netlify
Copy link

netlify bot commented Dec 4, 2025

Deploy Preview for dashboard-v2-novu-staging ready!

Name Link
🔨 Latest commit 30a2d29
🔍 Latest deploy log https://app.netlify.com/projects/dashboard-v2-novu-staging/deploys/6931a1e6e073660007b665f1
😎 Deploy Preview https://deploy-preview-9615.dashboard-v2.novu-staging.co
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@ChmaraX
Copy link
Contributor Author

ChmaraX commented Dec 4, 2025

@coderabbitai summary

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

✅ Actions performed

Summary regeneration triggered.

@github-actions github-actions bot changed the title fix(dashboard): validate namespace-only variables & centralize error msgs fix(dashboard): validate namespace-only variables & centralize error msgs fixes NV-6932 Dec 4, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 4, 2025

Walkthrough

This PR implements centralized variable error messaging by introducing a new utility function that generates contextual error strings, then threads this function through variable validation, editor plugins, and UI components. Namespace-only variable validation is added to catch single-part variables lacking proper namespace.

Changes

Cohort / File(s) Summary
Error Message Utility & Core Validation
apps/dashboard/src/components/variable/utils/get-variable-error-message.ts, apps/dashboard/src/utils/liquid.ts, apps/dashboard/src/utils/parseStepVariables.ts
Introduces new getVariableErrorMessage utility that generates contextual error strings for invalid variables. Adds isNamespaceOnlyVariable function to detect single-part variables lacking namespace, integrated into isAllowedVariable check.
Variable Validation Hook
apps/dashboard/src/components/variable/hooks/use-variable-validation.ts
Centralizes error message computation by using getVariableErrorMessage for both payload and non-payload branches. Upfront isAllowedVariable computation replaced with single early evaluation.
Variable Plugin Type & View
apps/dashboard/src/components/primitives/variable-plugin/types.ts, apps/dashboard/src/components/primitives/variable-plugin/index.ts, apps/dashboard/src/components/primitives/variable-plugin/plugin-view.ts
Extends PluginState type to include optional getVariableErrorMessage callback. Updates createVariableExtension and VariablePluginView constructor to accept and use error message function.
Variable Widget & Display
apps/dashboard/src/components/primitives/variable-plugin/variable-pill-widget.ts, apps/dashboard/src/components/variable/variable-pill.tsx, apps/dashboard/src/components/variable/variable-tooltip.tsx
Adds optional errorMessage parameter/prop throughout widget and component chain. Tooltip and rendering logic now display provided error message instead of hardcoded strings when applicable.
Variable View Integration
apps/dashboard/src/components/maily/views/variable-view.tsx
Updates VariablePill call sites to pass errorMessage and enhances isNotInSchema condition to account for validation.hasError.
Editor Integration
apps/dashboard/src/components/primitives/variable-editor.tsx
Imports and wires getVariableErrorMessage into variable extension creation flow, enabling contextual error messages for disallowed variables.
Maily Configuration
apps/dashboard/src/components/maily/maily-config.tsx
Simplifies variable insertion path by directly invoking onCreateNewVariable with full props.id and removing conditional branches for aliasFor validation and isAllowed checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Focus areas requiring extra attention:
    • get-variable-error-message.ts — New utility with namespace-only and payload schema validation logic; verify error message conditions align with requirements
    • use-variable-validation.ts — Restructured validation flow with upfront isAllowedVariable computation; ensure payload and non-payload branches produce correct hasError and errorMessage outputs
    • parseStepVariables.ts — New isNamespaceOnlyVariable integration affecting early-exit behavior for validation; verify ordering of checks does not introduce regressions
    • variable-pill-widget.ts — Changes to equality check (eq) now include errorMessage; confirm widget reuse/caching behavior remains correct

Possibly related PRs

Suggested reviewers

  • LetItRock
  • scopsy
  • djabarovgeorge

Poem

🐰 A rabbit hops through error paths,
With messages both clear and kind,
Namespace checks and schemas mapped,
No stray variables left behind!
From pill to tooltip, message flows,
Centralized, the rabbit knows! ✨

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch nv-6932-variables-highlight-invaliderrored-variables

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f00192 and 30a2d29.

📒 Files selected for processing (13)
  • apps/dashboard/src/components/maily/maily-config.tsx (1 hunks)
  • apps/dashboard/src/components/maily/views/variable-view.tsx (2 hunks)
  • apps/dashboard/src/components/primitives/variable-editor.tsx (2 hunks)
  • apps/dashboard/src/components/primitives/variable-plugin/index.ts (2 hunks)
  • apps/dashboard/src/components/primitives/variable-plugin/plugin-view.ts (3 hunks)
  • apps/dashboard/src/components/primitives/variable-plugin/types.ts (1 hunks)
  • apps/dashboard/src/components/primitives/variable-plugin/variable-pill-widget.ts (3 hunks)
  • apps/dashboard/src/components/variable/hooks/use-variable-validation.ts (4 hunks)
  • apps/dashboard/src/components/variable/utils/get-variable-error-message.ts (1 hunks)
  • apps/dashboard/src/components/variable/variable-pill.tsx (2 hunks)
  • apps/dashboard/src/components/variable/variable-tooltip.tsx (2 hunks)
  • apps/dashboard/src/utils/liquid.ts (2 hunks)
  • apps/dashboard/src/utils/parseStepVariables.ts (2 hunks)

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@ChmaraX ChmaraX merged commit 6d1169c into next Dec 4, 2025
36 of 38 checks passed
@ChmaraX ChmaraX deleted the nv-6932-variables-highlight-invaliderrored-variables branch December 4, 2025 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants