You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kie.apache.org by "rajalakshmys-27 (via GitHub)" <gi...@apache.org> on 2026/05/10 16:29:56 UTC

[PR] Filter parsererror elements from XML parsing to prevent file corruption [incubator-kie-tools]

rajalakshmys-27 opened a new pull request, #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570

   Closes: [kie-issues#2301](https://github.com/apache/incubator-kie-issues/issues/2301)
   
   When a faulty BPMN/DMN/SCESIM file is opened, any modification and export causes a `<parsererror>` element to appear at the top level of the exported XML, corrupting the file on every edit-export cycle.
   
   **Example faulty file:** https://gist.githubusercontent.com/rajalakshmys-27/28e82fd3de60d656a28a0ab654401e32/raw/855f4fc030cd560d66e6b2cb7107134e1518c90b/parseerror.bpmn
   
   ### Root Cause
   `<parsererror>` is automatically injected by the browser's DOMParser (and jsdom in Node.js) when it encounters schema violations such as elements in wrong locations, invalid attributes, or incorrect nesting. This is standard W3C behavior and cannot be disabled.
   
   ### Fix
   Filter out `<parsererror>` elements in `xml-parser-ts` immediately after parsing, before the document is returned to any marshaller. This single fix protects all marshallers (BPMN, DMN, SCESIM) automatically with no changes required elsewhere.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "rajalakshmys-27 (via GitHub)" <gi...@apache.org>.
rajalakshmys-27 commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4546135087

   Thanks! I’ve tried out showing a UI error, verified the xml. 
   
   https://github.com/user-attachments/assets/60536ed3-64d7-4839-afb6-93f84b3216ec
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4487793561

   @rajalakshmys-27 I understand the problem. We have two times where the `parsererror` appears - when we open the file, and when we save the file. The error looks worse on KIE Sandbox as it auto-save after every new edit. If we prevent new edits, we will not have the problem of adding multiple `parsererrors`.
   
   I agree we should remove the `parsererror` from the XML, but just this is not the complete fix. Can't we remove the `parsererror` and prevent new edits? We already have a screen to show parser errors.
   
   Another option is we could fix the XML structure (erasing any element that is in the wrong place), but I'm not sure about the difficulty of doing it.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4482715608

   @rajalakshmys-27 Thanks for your PR. I'm not sure if this is the correct way to proceed as the XML is not fixed after filtering out the `parsererror` tag. Users will still have a broken BPMN file even after editing it. I believe the correct approach is to fix the parse error if we erase the `parsererror` tag, or we show an error message on the editor. WDYT?
   cc @thiagoelg 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "rajalakshmys-27 (via GitHub)" <gi...@apache.org>.
rajalakshmys-27 commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4554400907

   @ljmotta But I was able to see the Error UI (parse error removed) in both webapp & vscode extension 
   
   https://github.com/user-attachments/assets/db3b1788-8dff-4c8d-86fe-4538b12a183a
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "rajalakshmys-27 (via GitHub)" <gi...@apache.org>.
rajalakshmys-27 commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4485341270

   @jomarko Thanks for the suggestions!
   
   I'll add a comment in the code referencing kie-issues#2301 to make it easier to understand the context behind this change in the future.
   
   As for the e2e test, we'd prefer not to block the bug fix on it, but we'll make sure to add one as a follow-up once this is merged. 
   cc @thiagoelg


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "rajalakshmys-27 (via GitHub)" <gi...@apache.org>.
rajalakshmys-27 commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4485328165

   @ljmotta Thanks for the review!
   
   Just to clarify the intent of this fix - the problem it solves is specifically the **re-injection bug**: when a faulty file is opened, the browser's DOMParser automatically adds a `<parsererror>` node, which then gets serialised back into the exported XML on every edit-export cycle, making the corruption worse with each save. Filtering it out at the `xml-parser-ts` level stops that re-injection.
   
   This approach was also what @tiagobento suggested as a fallback after exploring whether the DOMParser behaviour could be customised (it can't, it's standard W3C behaviour).
   
   That said, you raise a completely valid point: the user's file is still broken even after filtering, and silently allowing edits on a malformed file isn't a great experience. I agree we should also surface an error in the editor when a `<parsererror>` is detected on load, something that makes it clear the file is malformed and that edits may not be reliable.
   
   Would it make sense to handle both in this PR, or would you prefer to track the error UI as a separate follow-up? Happy to go either way. 
   cc @thiagoelg


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "ljmotta (via GitHub)" <gi...@apache.org>.
ljmotta commented on PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570#issuecomment-4554228054

   I've tried with the BPMN Editor on the dev webapp and I couldn't make the error screen appear. I didn't see the error screen on VS Code too.
   
   
   https://github.com/user-attachments/assets/23504732-e6d9-435f-9a8a-fa8be5ec3490
   
   
   https://github.com/user-attachments/assets/b8f77bdb-3765-4442-bb21-91301f173e8c
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org


Re: [PR] kie-issues#2301: BPMN Editor: Opening faulty XML will add a element to the top-level [incubator-kie-tools]

Posted by "thiagoelg (via GitHub)" <gi...@apache.org>.
thiagoelg merged PR #3570:
URL: https://github.com/apache/incubator-kie-tools/pull/3570


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@kie.apache.org
For additional commands, e-mail: commits-help@kie.apache.org