Skip to content

Fix ExtendedNodeId not correctly json encoded #3209#3211

Merged
mrsuciu merged 1 commit into
masterfrom
issue3209
Sep 18, 2025
Merged

Fix ExtendedNodeId not correctly json encoded #3209#3211
mrsuciu merged 1 commit into
masterfrom
issue3209

Conversation

@marcschier

@marcschier marcschier commented Sep 16, 2025

Copy link
Copy Markdown
Collaborator

Proposed changes

Describe the changes here to communicate to the maintainers why we should accept this pull request. If it fixes a bug or resolves a feature request, be sure to link to that issue.

Related Issues

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply. You can also fill these out after creating the PR.

  • Bugfix (non-breaking change which fixes an issue)
  • Enhancement (non-breaking change which adds functionality)
  • Test enhancement (non-breaking change to increase test coverage)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected, requires version increase of Nuget packages)
  • Documentation Update (if none of the other choices apply)

Checklist

Put an x in 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.

  • I have read the CONTRIBUTING doc.
  • I have signed the CLA.
  • I ran tests locally with my changes, all passed.
  • I fixed all failing tests in the CI pipelines.
  • I fixed all introduced issues with CodeQL and LGTM.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added necessary documentation (if appropriate).
  • Any dependent changes have been merged and published in downstream modules.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

@codecov

codecov Bot commented Sep 16, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 57.47%. Comparing base (4d80ba7) to head (48edb61).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3211      +/-   ##
==========================================
+ Coverage   57.42%   57.47%   +0.04%     
==========================================
  Files         355      355              
  Lines       78540    78540              
  Branches    13855    13855              
==========================================
+ Hits        45104    45139      +35     
+ Misses      29182    29149      -33     
+ Partials     4254     4252       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in ExtendedNodeId JSON encoding where the JSON structure was not properly closed when ServerUri was present. It also modernizes test code by updating string formatting from concatenation and interpolation to raw string literals.

  • Fixes incorrect JSON encoding for ExtendedNodeId with ServerUri by moving PopStructure() call outside the conditional block
  • Updates all test string literals to use C# 11+ raw string literal syntax ("""...""") for better readability
  • Adds comprehensive test case for ExtendedNodeId with ServerUri to verify the fix

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs Fixes JSON structure closure bug by moving PopStructure() call outside ServerUri conditional
Tests/Opc.Ua.Core.Tests/Types/Encoders/JsonEncoderTests.cs Updates test strings to raw literals and adds test case for ExtendedNodeId with ServerUri

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread Stack/Opc.Ua.Core/Types/Encoders/JsonEncoder.cs
Comment thread Tests/Opc.Ua.Core.Tests/Types/Encoders/JsonEncoderTests.cs

@hermotech hermotech left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes the issue the same way I tested in parallel.
Thank you!

@hermotech

hermotech commented Sep 16, 2025

Copy link
Copy Markdown
Contributor

@marcschier

Thanks for the quick action on the bug report and providing a fix. Much appreciated!

We unfortunately have a blocker that prevents us from updating to the latest version of the packages.
We currently reference 1.5.374.158.

The blocker can be explained as follows:

Currently we serialize alarm event fields using serializer.Serialize() and not the JsonEncoder.
We recently discovered a breaking change in the resulting json schema after we updated package references to a more recent version. This is a blocker for our customers.

We cannot easily and quickly get customers to change to a new schema (result of regular system serialization with newer versions)
This prevents us from updating package references to take advantage of bug fixes etc.

We need the JsonEncoder fix here as a patch for the 1.5.374.* release so that we can introduce a new feature that will use JsonEncoder with the fix here, but still maintain the same json schema we achieve for the existing feature where JsonEncoder is not yet used.

Would it be possible to cherry pick the fix for JsonEncoder here to the 374 branch so that a patch can be released?
This way we will not have the schema issue with serializer.Serialize(), but we can already take benefit of the fix for the JsonEncoder for new features and in the meantime steadily migrate the other features to the use of JsonEncoder instead of system serialization?

@mrsuciu
mrsuciu merged commit 2dbff3a into master Sep 18, 2025
120 checks passed
mrsuciu pushed a commit to mrsuciu/UA-.NETStandard that referenced this pull request Sep 18, 2025
@romanett
romanett deleted the issue3209 branch October 27, 2025 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JsonEncoder not correctly closing JSON for ExpandedNodeId - missing curly bracket

4 participants