fix: validate encoded telemetry message size - #1241
Draft
Carter Tinney (cartertinney) wants to merge 3 commits into
Draft
fix: validate encoded telemetry message size#1241Carter Tinney (cartertinney) wants to merge 3 commits into
Carter Tinney (cartertinney) wants to merge 3 commits into
Conversation
Measure IoT Hub messages from their encoded payload and logical property contribution instead of CPython object layout, and make boundary coverage deterministic across supported Python versions. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Carter Tinney (cartertinney)
marked this pull request as draft
August 21, 2026 23:27
Copilot started reviewing on behalf of
Carter Tinney (cartertinney)
August 22, 2026 05:33
View session
There was a problem hiding this comment.
Pull request overview
Replaces Python object-size telemetry validation with deterministic IoT Hub byte accounting.
Changes:
- Measures encoded payload and normalized property sizes.
- Includes module output names before validation.
- Adds exact 256-KB boundary coverage for sync and async clients.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
azure-iot-device/azure/iot/device/iothub/models/message.py |
Implements deterministic message sizing. |
azure-iot-device/azure/iot/device/iothub/pipeline/mqtt_topic_iothub.py |
Shares property normalization with sizing. |
azure-iot-device/azure/iot/device/iothub/sync_clients.py |
Includes output name in sync validation. |
azure-iot-device/azure/iot/device/iothub/aio/async_clients.py |
Includes output name in async validation. |
tests/unit/iothub/models/test_message.py |
Tests encoding and size boundaries. |
tests/unit/iothub/test_sync_clients.py |
Tests synchronous boundary validation. |
tests/unit/iothub/aio/test_async_clients.py |
Tests asynchronous boundary validation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Ewerton Scaboro da Silva (ewertons)
approved these changes
Aug 24, 2026
| import urllib | ||
|
|
||
| from azure.iot.device.iothub.models.message import ( | ||
| _get_custom_properties, |
Contributor
There was a problem hiding this comment.
Excellent!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sys.getsizeof()telemetry validation with deterministic IoT Hub message accounting: encoded body bytes, outgoing system-property values, and custom-property names and valuesstras UTF-8,int/floatas ASCII,Noneas empty, andbytes/bytearrayas-is) while excluding MQTT topic and packet overheadBehavior and compatibility
IoT Hub defines message size independently of the transport as body bytes plus system-property values plus application-property names and values. The old implementation measured CPython object allocation instead, so identical messages could validate differently across Python versions.
This change intentionally affects messages near the 256-KB boundary:
TypeErrorinstead of later in the publish call; the accepted payload type set is unchangedThe MQTT topic encoding itself is unchanged; sizing and encoding now consume the same normalized property values to prevent drift.
Validation
test_alarm.pyandtest_sync_handler_manager.py; every failure passed immediately in isolationtest_alarm.pytiming-window failure; it passed immediately in isolationflake8andgit diff --check