Validate automation email Lexical documents#28725
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (5)
WalkthroughThe pull request adds a Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
| Command | Status | Duration | Result |
|---|---|---|---|
nx run ghost:test:ci:integration |
✅ Succeeded | 2m 18s | View ↗ |
nx run ghost:test:ci:integration:no-coverage |
✅ Succeeded | 2m 24s | View ↗ |
nx run ghost:test:ci:legacy |
✅ Succeeded | 2m 52s | View ↗ |
nx run ghost:test:ci:e2e |
✅ Succeeded | 2m 27s | View ↗ |
nx run ghost:test:ci:e2e:no-coverage |
✅ Succeeded | 2m 11s | View ↗ |
nx build @tryghost/portal |
✅ Succeeded | 1s | View ↗ |
nx build @tryghost/signup-form |
✅ Succeeded | <1s | View ↗ |
nx build @tryghost/comments-ui |
✅ Succeeded | <1s | View ↗ |
Additional runs (10) |
✅ Succeeded | ... | View ↗ |
💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗
☁️ Nx Cloud last updated this comment at 2026-06-22 23:16:48 UTC
ae249d3 to
5148e6d
Compare
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@ghost/core/core/server/lib/lexical.js`:
- Around line 116-124: The validate() method currently only uses userOptions
when creating the lexicalValidationRenderer, but the render() method supplies
additional Ghost defaults like siteUrl, image options, feature flags, and custom
nodeRenderers. Extract the option-building logic from the render() method (lines
90-111 in the diff context) and reuse it in the validate() method so that the
validation renderer is called with the same complete set of defaults as the
normal render() method, ensuring that valid documents depending on those
defaults are not incorrectly rejected during validation.
In `@ghost/core/core/server/services/automations/automations-api.ts`:
- Around line 117-118: The validateActiveEmailSteps function calls
isEmptyLexical internally, which catches malformed JSON errors and returns true,
causing the API to report an emptyEmailBodyWhenActive error instead of the
proper invalid-Lexical error. Swap the order of the two validation calls so that
validateEmailLexical executes before validateActiveEmailSteps, ensuring that
malformed Lexical content is properly detected and reported with the correct
error classification before the active-body emptiness check runs.
- Around line 182-193: In the isEmptyParsedLexical function, the current check
for whether a paragraph's children field is empty is too permissive. The
condition `!children[0].children || children[0].children.length === 0` treats
missing, null, or malformed children values as empty. Replace this logic to
explicitly require that children[0].children is an array before considering the
paragraph empty, so that only a valid empty array is treated as an empty
paragraph, rejecting malformed Lexical data.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 08cd6934-7bde-47d3-93b6-33a988c726d4
⛔ Files ignored due to path filters (1)
ghost/core/test/e2e-api/admin/__snapshots__/automations.test.js.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
ghost/core/core/server/api/endpoints/utils/validators/input/automation_email_previews.jsghost/core/core/server/lib/lexical.jsghost/core/core/server/services/automations/automations-api.tsghost/core/test/unit/server/lib/lexical.test.jsghost/core/test/unit/server/services/automations/automations-api.test.jsghost/core/test/utils/automations-fixtures.ts
5148e6d to
7fdbbd4
Compare

closes https://linear.app/ghost/issue/NY-1284
Don't just check whether the JSON is valid: check that it's valid Lexical.
Manually tested this by editing an email and it worked fine.