Skip to content

Add application validation for transmission counts to prevent overflow #3165

@coderabbitai

Description

@coderabbitai

Context

In DialogTransmissionAppender.Append, transmission counts are cast to short when updating FromPartyTransmissionsCount and FromServiceOwnerTransmissionsCount:

dialog.FromPartyTransmissionsCount += (short)fromParty;
dialog.FromServiceOwnerTransmissionsCount += (short)fromServiceOwner;

Currently, a checked cast will be added to throw an exception on overflow, but this should be complemented with application-level validation that prevents the overflow scenario from occurring in the first place.

Proposed Solution

Add validation logic that:

  1. Checks if the new transmission counts would exceed short.MaxValue (32,767) before performing the cast
  2. Returns a clear validation error to the caller if the limit would be exceeded
  3. Prevents the need to catch overflow exceptions during normal operation

This validation should be added at the command/DTO validation level where appropriate, so users receive a clear error message rather than an exception.

Backlinks

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

New issues

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions