fix: handle null declaration in DocxExporter to prevent export crash#2378
Open
aldrinjenson wants to merge 1 commit intosuperdoc-dev:mainfrom
Open
fix: handle null declaration in DocxExporter to prevent export crash#2378aldrinjenson wants to merge 1 commit intosuperdoc-dev:mainfrom
aldrinjenson wants to merge 1 commit intosuperdoc-dev:mainfrom
Conversation
When exporting a SuperDoc to DOCX, if the converter's declaration is null (e.g., for documents created/edited via Yjs collaboration without raw XML import), the export crashes with: TypeError: Cannot read properties of null (reading 'attributes'). Add optional chaining and a standard XML declaration fallback (version="1.0" encoding="UTF-8" standalone="yes") so export succeeds when converter.declaration is null or undefined. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
TypeError: Cannot read properties of null (reading 'attributes')crash when exporting a SuperDoc to DOCXDocxExporter.#generate_xml_as_listwhenconverter.declarationis null — which happens for documents created/edited via Yjs collaboration that were never initialized from raw XMLversion="1.0" encoding="UTF-8" standalone="yes")Root Cause
exporter.jsline 580 accessedthis.converter.declaration.attributeswithout a null check.SuperConverter.declarationis initialized asnullin the constructor and only populated inparseFromXml(), which isn't called for Yjs-only documents.Test plan
🤖 Generated with Claude Code