Skip to content

Treat zero MaxNotificationsPerPublish as unlimited (OPC 10000-4) - #4047

Merged
marcschier merged 4 commits into
OPCFoundation:masterfrom
marcschier:marcschier/review-fix/max-notifications-zero
Jul 23, 2026
Merged

Treat zero MaxNotificationsPerPublish as unlimited (OPC 10000-4)#4047
marcschier merged 4 commits into
OPCFoundation:masterfrom
marcschier:marcschier/review-fix/max-notifications-zero

Conversation

@marcschier

@marcschier marcschier commented Jul 19, 2026

Copy link
Copy Markdown
Collaborator

Description

This focused change extracts the MaxNotificationsPerPublish conformance fix from #4021. It contains only Subscription.cs, SubscriptionManager.cs, and focused SubscriptionTests.

Failure

OPC UA defines zero as no notification limit. The message builder compared the queued count directly with zero, so an effective zero limit emitted no event or data-change notifications and left the queues pending. Separately, the revision logic treated a configured Server maximum of zero as a numeric cap, revising a non-zero Client request to zero and silently removing the Client's requested limit.

Fix

  • Treat an effective zero limit as unlimited while draining event and data-change queues.
  • When the Client requests zero, use the Server's configured maximum, which may itself remain zero/unlimited.
  • When the Server maximum is zero, preserve a non-zero Client request, including uint.MaxValue.
  • When the Server maximum is finite, cap zero, uint.MaxValue, and larger finite Client requests to that maximum.
  • Cover the same revision matrix through both CreateSubscription and ModifySubscription.

This implements the zero-means-unlimited semantics in OPC 10000-4 v1.05.07 Sections 5.14.2.2 and 5.14.3.2. Those Service responses do not contain a revisedMaxNotificationsPerPublish field; the effective value is retained by the Server-side Subscription and its diagnostics.

Tests

  • dotnet test tests\Opc.Ua.Server.Tests\Opc.Ua.Server.Tests.csproj -f net10.0 --filter "FullyQualifiedName~Opc.Ua.Server.Tests.SubscriptionTests" --no-restore: 25 passed.
  • dotnet test tests\Opc.Ua.Server.Tests\Opc.Ua.Server.Tests.csproj -f net48 --filter "FullyQualifiedName~Opc.Ua.Server.Tests.SubscriptionTests" --no-restore: 25 passed.

The regression tests cover zero, finite, and uint.MaxValue Client requests against unlimited and finite Server limits for both CreateSubscription and ModifySubscription. They also verify that zero drains both event and data-change queues.

Related Issues

Checklist

  • I have signed the CLA and read the CONTRIBUTING doc.
  • I have added tests that prove my fix is effective or that my feature works and increased code coverage.
  • I have added all necessary documentation.
  • I have verified that my changes do not introduce (new) build or analyzer warnings.
  • I ran all tests locally using the UA.slnx solution against at least .net framework and .net 10, and all passed.
  • I fixed all failing and flaky tests in the CI pipelines and all CodeQL warnings.
  • I have addressed all PR feedback received.

Preserve client limits when the server has no configured cap and drain notification queues when the effective limit is zero.

Implements OPC 10000-4 Sections 5.13.2.2 and 5.13.3.2.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 10:47
Copilot AI review requested due to automatic review settings July 19, 2026 10:47

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

Note

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Implements OPC UA “zero means unlimited” semantics for MaxNotificationsPerPublish, ensuring publish message construction drains notification queues when the effective limit is 0, and revising client-requested limits correctly against the server maximum.

Changes:

  • Update subscription publish message construction to treat an effective 0 notification limit as unlimited.
  • Fix max-notifications revision logic in SubscriptionManager to preserve non-zero client requests when the server max is 0/unlimited.
  • Add regression tests for queue draining with a zero limit and for client/server limit revision behavior.

Reviewed changes

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

File Description
src/Opc.Ua.Server/Subscription/Subscription.cs Treats server-side effective 0 as unlimited during message construction so queues drain.
src/Opc.Ua.Server/Subscription/SubscriptionManager.cs Revises requested MaxNotificationsPerPublish using OPC UA zero/unlimited rules.
tests/Opc.Ua.Server.Tests/SubscriptionTests.cs Adds targeted regression tests for zero/unlimited semantics and revision logic.

Comment thread tests/Opc.Ua.Server.Tests/SubscriptionTests.cs Outdated
Comment thread tests/Opc.Ua.Server.Tests/SubscriptionTests.cs Outdated
Comment thread tests/Opc.Ua.Server.Tests/SubscriptionTests.cs Outdated
Comment thread tests/Opc.Ua.Server.Tests/SubscriptionTests.cs Outdated
Comment thread src/Opc.Ua.Server/Subscription/Subscription.cs
@marcschier
marcschier marked this pull request as draft July 19, 2026 11:36
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 11:55
@marcschier
marcschier marked this pull request as draft July 19, 2026 12:12
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 14:13
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@marcschier
marcschier marked this pull request as draft July 19, 2026 16:47
@marcschier
marcschier marked this pull request as ready for review July 19, 2026 16:57
@marcschier
marcschier requested a review from romanett July 19, 2026 18:37
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 91.66667% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 73.74%. Comparing base (70c74e7) to head (7b0dc84).
⚠️ Report is 40 commits behind head on master.

Files with missing lines Patch % Lines
src/Opc.Ua.Server/Subscription/Subscription.cs 85.71% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4047      +/-   ##
==========================================
+ Coverage   73.55%   73.74%   +0.18%     
==========================================
  Files        1345     1352       +7     
  Lines      180036   182979    +2943     
  Branches    31677    32148     +471     
==========================================
+ Hits       132427   134929    +2502     
- Misses      36911    37253     +342     
- Partials    10698    10797      +99     
Files with missing lines Coverage Δ
.../Opc.Ua.Server/Subscription/SubscriptionManager.cs 74.58% <100.00%> (+1.28%) ⬆️
src/Opc.Ua.Server/Subscription/Subscription.cs 75.21% <85.71%> (+0.29%) ⬆️

... and 97 files with indirect coverage changes

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

Comment thread src/Opc.Ua.Server/Subscription/Subscription.cs
@marcschier marcschier added the needs changes PR needs more changes label Jul 23, 2026
@marcschier marcschier added ready Ready to merge once CI Passes and removed needs changes PR needs more changes labels Jul 23, 2026
@marcschier
marcschier merged commit a5dd6ea into OPCFoundation:master Jul 23, 2026
162 of 163 checks passed
@marcschier
marcschier deleted the marcschier/review-fix/max-notifications-zero branch July 23, 2026 12:19
marcschier pushed a commit that referenced this pull request Aug 18, 2026
## Proposed changes

Backport commit
a5dd6ea
(#4047) to `master378`.

OPC UA defines zero as no notification limit. The message builder
compared the queued count directly with zero, so an effective zero limit
emitted no event or data-change notifications and left the queues
pending. Separately, the revision logic treated a configured Server
maximum of zero as a numeric cap, revising a non-zero Client request to
zero and silently removing the Client's requested limit.

### Fix
- Treat an effective zero limit as unlimited while draining event and
data-change queues.
- When the Client requests zero, use the Server's configured maximum,
which may itself remain zero/unlimited.
- When the Server maximum is zero, preserve a non-zero Client request,
including `uint.MaxValue`.
- When the Server maximum is finite, cap zero, `uint.MaxValue`, and
larger finite Client requests to that maximum.
- Cover the same revision matrix through both CreateSubscription and
ModifySubscription.

## Related Issues

- Backport of #4047 (commit `a5dd6eae7cc1ab074d62d723194285952560555f`)

## Types of changes

- [x] Bugfix (non-breaking change which fixes an issue)
- [ ] Enhancement (non-breaking change which adds functionality)
- [x] 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

- [x] I have read the
[CONTRIBUTING](https://github.com/OPCFoundation/UA-.NETStandard/blob/master/CONTRIBUTING.md)
doc.
- [x] I have signed the
[CLA](https://opcfoundation.org/license/cla/ContributorLicenseAgreementv1.0.pdf).
- [x] 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.
- [x] I have added tests that prove my fix is effective or that my
feature works and increased code coverage.
- [x] I have added necessary documentation (if appropriate).
- [ ] Any dependent changes have been merged and published in downstream
modules.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready Ready to merge once CI Passes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants