Skip to content
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

Merged
merged 6 commits into from
Feb 4, 2020
Merged

Conversation

olivakar
Copy link
Collaborator

No description provided.

@olivakar olivakar force-pushed the ok-message-size branch 2 times, most recently from 8d005fb to c36baf2 Compare January 29, 2020 20:39
@@ -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
Copy link
Member

@BertKleewein BertKleewein Jan 30, 2020

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

@BertKleewein
Copy link
Member

BertKleewein commented Jan 30, 2020

def send_message(self, message):

Do we have a limit for the size of messages for send_message_to_output? #Resolved


Refers to: azure-iot-device/azure/iot/device/iothub/sync_clients.py:129 in ce5d4ad. [](commit_id = ce5d4ad, deletion_comment = False)

@BertKleewein
Copy link
Member

def send_message(self, message):

I will test and tell you. I'm poking in the right area and can do this quickly.


In reply to: 580416150 [](ancestors = 580416150)


Refers to: azure-iot-device/azure/iot/device/iothub/sync_clients.py:129 in ce5d4ad. [](commit_id = ce5d4ad, deletion_comment = False)

Copy link
Member

@BertKleewein BertKleewein left a comment

Choose a reason for hiding this comment

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

:shipit:

@BertKleewein
Copy link
Member

def send_message(self, message):

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)

Copy link
Member

@BertKleewein BertKleewein left a 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.")
Copy link
Member

@BertKleewein BertKleewein Feb 4, 2020

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:
Copy link
Member

@BertKleewein BertKleewein Feb 4, 2020

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(
Copy link
Member

@BertKleewein BertKleewein Feb 4, 2020

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

Copy link
Collaborator Author

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)

Copy link
Member

@BertKleewein BertKleewein left a comment

Choose a reason for hiding this comment

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

:shipit:

@olivakar olivakar merged commit 477ae00 into master Feb 4, 2020
@olivakar olivakar deleted the ok-message-size branch February 13, 2020 22:39
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.

2 participants