Summary
When attempting to save a draft of a blog post with AI-generated content, the WordPress editor crashes with an 'unexpected error' message, preventing users from saving their work.
Screenshot
The error displays: 'The editor has encountered an unexpected error' with options to 'Copy Post Text' or 'Copy Error'
Location: /home/timl/dev/WP_ContentFlow/tmp/Screenshot 2025-09-11 061421.png
WordPress Environment
- WordPress Version: 6.0+
- PHP Version: 8.1+
- Browser: Chrome/Edge (latest)
- Plugin Version: 1.0.0
- Theme: Default WordPress theme
Steps to Reproduce
- Log into WordPress admin dashboard
- Navigate to Posts → Add New
- Add the AI Text Generator block to the post
- Generate content using the AI block
- Attempt to save the post as a draft
- Editor crashes with 'The editor has encountered an unexpected error'
Expected Behavior
- Post should save successfully as a draft
- AI-generated content should be preserved
- Editor should remain stable and functional
Actual Behavior
- Editor crashes with unexpected error
- Post cannot be saved
- User loses all work if page is refreshed
- Error appears immediately upon save attempt
Technical Analysis
Potential causes:
- Block Validation Error: The AI Text Generator block may be producing invalid HTML that breaks Gutenberg's validation
- JavaScript Conflict: Async state updates in the block may be conflicting with WordPress save process
- REST API Error: The save request may be failing due to malformed data from the AI block
- React State Issue: The block's React state may be corrupted during content generation
Impact
- Critical: Users cannot save any posts containing AI-generated content
- Data Loss: Users lose all work when editor crashes
- Workflow Blocking: Core functionality of the plugin is broken
Acceptance Criteria
Testing Requirements
- Unit Tests: Validate block output structure
- Integration Tests: Test save process with AI content
- E2E Tests: Full workflow from content generation to draft save
- Browser Testing: Verify across Chrome, Firefox, Safari, Edge
Priority
P1 - Critical: This is a complete blocker for the plugin's core functionality. Users cannot use the plugin if they cannot save posts.
Related Components
blocks/ai-text-generator/index.js - Block implementation
assets/js/blocks.js - Block registration and state management
- WordPress Gutenberg block editor
- WordPress REST API save endpoint
Suggested Fix Approach
- Add proper error boundaries to the React component
- Validate generated HTML before setting block attributes
- Implement proper cleanup in useEffect hooks
- Add defensive checks for undefined/null values in save function
- Test with WordPress debug mode enabled to capture detailed errors
Next Steps for Developer
- Click 'Copy Error' button in the screenshot to get full stack trace
- Check browser console for JavaScript errors
- Enable WordPress debug logging (WP_DEBUG, WP_DEBUG_LOG)
- Test with minimal plugin setup to isolate conflict
- Review block's save() function for serialization issues
Summary
When attempting to save a draft of a blog post with AI-generated content, the WordPress editor crashes with an 'unexpected error' message, preventing users from saving their work.
Screenshot
The error displays: 'The editor has encountered an unexpected error' with options to 'Copy Post Text' or 'Copy Error'
Location: /home/timl/dev/WP_ContentFlow/tmp/Screenshot 2025-09-11 061421.png
WordPress Environment
Steps to Reproduce
Expected Behavior
Actual Behavior
Technical Analysis
Potential causes:
Impact
Acceptance Criteria
Testing Requirements
Priority
P1 - Critical: This is a complete blocker for the plugin's core functionality. Users cannot use the plugin if they cannot save posts.
Related Components
blocks/ai-text-generator/index.js- Block implementationassets/js/blocks.js- Block registration and state managementSuggested Fix Approach
Next Steps for Developer