-
Notifications
You must be signed in to change notification settings - Fork 382
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(azure-iot-device): Message size checks #447
Conversation
8d005fb
to
c36baf2
Compare
c36baf2
to
ce5d4ad
Compare
@@ -11,3 +11,4 @@ | |||
IOTHUB_API_VERSION = "2018-06-30" | |||
PROVISIONING_API_VERSION = "2019-03-31" | |||
SECURITY_MESSAGE_INTERFACE_ID = "urn:azureiot:Security:SecurityAgent:1" | |||
SIZE_LIMIT = 262144 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SIZE_LIMIT [](start = 0, length = 10)
size of what? I suggest adding what size this limits. (e.g. TELEMETRY_MESSAGE_SIZE_LIMIT) #Closed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The answer is: We need to add this code to send_message_to_output also because it fails if message size > 256 KB In reply to: 580416322 [](ancestors = 580416322,580416150) Refers to: azure-iot-device/azure/iot/device/iothub/sync_clients.py:129 in ce5d4ad. [](commit_id = ce5d4ad, deletion_comment = False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🕐
@@ -454,6 +460,10 @@ def send_message_to_output(self, message, output_name): | |||
""" | |||
if not isinstance(message, Message): | |||
message = Message(message) | |||
|
|||
if message.get_size() > device_constant.TELEMETRY_MESSAGE_SIZE_LIMIT: | |||
raise ValueError("Size of telemetry message can not exceed 256 KB.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
raise ValueError [](start = 12, length = 16)
Don't forget to add :raises: for this to the docstring above. I would also remove the word "telemetry" from the exception string ("Size of message can not exceed 256 KB"
#Resolved
@@ -417,6 +422,9 @@ def __init__(self, iothub_pipeline, http_pipeline): | |||
if not isinstance(message, Message): | |||
message = Message(message) | |||
|
|||
if message.get_size() > device_constant.TELEMETRY_MESSAGE_SIZE_LIMIT: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
message [](start = 11, length = 7)
same comment from sync_client.py on :raises: doc and exception message. #Resolved
assert iothub_pipeline.send_output_event.call_count == 0 | ||
|
||
@pytest.mark.it("Does not raises error when message data size is equal to 256 KB") | ||
async def test_raises_error_when_message_to_output_data_equal_to_256( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test_raises_error_when_message_to_output_data_equal_to_256 [](start = 14, length = 58)
I go back and forth on the utility of the equal_to_256 tests. I don't think I would be sad to see them disappear. #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to keep it to check the boundary..but right now it is not serving any purpose. but i do want to address it after i do the content type and content encoding as things are bound to change then.
In reply to: 374956555 [](ancestors = 374956555)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No description provided.