Repository navigation
XmlDecoder/XmlParser: throw BadDecodingError for empty/non-element enumerated arrays - #3677
Conversation
|
|
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/ddcb3263-7df3-4480-bc3e-ac2a12f86a3f Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
|
@copilot check xmlparser class peek has the same issue and if so fix also. |
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/8f707c40-f91f-4898-aaf0-7428d76538ba Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/8f707c40-f91f-4898-aaf0-7428d76538ba Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Checked XmlParser and it had the same |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3677 +/- ##
==========================================
- Coverage 71.74% 71.67% -0.08%
==========================================
Files 521 519 -2
Lines 115264 115037 -227
Branches 19451 19442 -9
==========================================
- Hits 82697 82451 -246
- Misses 26981 26994 +13
- Partials 5586 5592 +6 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@copilot fix the now failing ReadEnumeratedArrayThrowsBadDecodingErrorWhenNoElementsPresent test. |
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/028b1b56-f9ef-40a0-a48f-cd725faf214b Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Fixed in aa530c4. The parser now checks for an actual child element ( |
|
@copilot check again, ReadEnumeratedArrayThrowsBadDecodingErrorWhenNoElementsPresent still fails. |
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/9ad10c5f-e2fc-4a8c-ac20-3ba21689d7c0 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Fixed in 63d2b48 (core behavior fix is in c472268). |
|
@copilot now ReadEnumeratedThrowsWhenInvalid is failing, please fix and ensure no other tests break |
Agent-Logs-Url: https://github.com/OPCFoundation/UA-.NETStandard/sessions/31c10ef5-2c00-478c-a488-62c19798b9f4 Co-authored-by: marcschier <11168470+marcschier@users.noreply.github.com>
Fixed in 9fe1661. I removed the incorrect empty-array message assertion from |
Proposed changes
ReadEnumeratedArray(string)in the XML decoder implementations could fail to handle arrays with no decodable child elements correctly.This PR hardens both implementations so they consistently throw a
ServiceResultException(BadDecodingError) for empty/non-element enumerated arrays and adds regression coverage for the parser edge cases found in review.Decoder/parser behavior hardening
Stack/Opc.Ua.Types/Encoders/XmlDecoder.cs, added a guard after:BadDecodingErrorwhenxmlNameisnull.Stack/Opc.Ua.Types/Encoders/XmlParser.cs, fixed the empty-field path soReadEnumeratedArray(string)also throwsBadDecodingErrorwhen the field exists but has no decodable child elements (including empty/text-only content), while preserving nil/missing-field behavior.Regression test coverage
ReadEnumeratedArrayThrowsWhenNoElementsPresentin:Tests/Opc.Ua.Types.Tests/Encoders/XmlDecoderTests.csXmlParsernon-generic array coverage in:Tests/Opc.Ua.Types.Tests/Encoders/XmlParserTests.cs, including:CDATA/no elements) throwsBadDecodingErrorBadDecodingErrorBadDecodingErrorArrayOf<EnumValue>ArrayOf<EnumValue>Follow-up feedback fix
ReadEnumeratedThrowsWhenInvalid(XmlParserTests) by removing an incorrect assertion that expected the empty-array error message for invalid enum parsing.Opc.Ua.Types.Tests.Related Issues
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that apply. You can also fill these out after creating the PR.Checklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
Scope remains intentionally narrow: runtime hardening in
XmlDecoder/XmlParserplus focused regression tests forXmlParsernon-generic enumerated array behavior and a follow-up correction to the invalid-enum test assertion. Existing successful array decoding and encoding-limit behavior are unchanged.