eclipse-leshan / leshan

Java Library for LWM2M
https://www.eclipse.org/leshan/
BSD 3-Clause "New" or "Revised" License
653 stars 408 forks source link

Fail to decode empty response to a Read operation #1622

Open dnav opened 5 months ago

dnav commented 5 months ago

Version(s)

2.0.0-SNAPSHOT (leshan.eclipseprojects.io)

Which components

leshan.eclipseprojects.io

Tested With

custom CoAP server

What happened

When performing a Read operation returning an empty response, Leshan returns an "failed to decode" error in some case.

I tested a Read on an empty Object (no Object Instance), an empty Object Instance (no readable Resource, object ID 7), and an empty multiple Resource (no Resource Instance).

The response is always a 2.05 content with or witout a content-format option, and with or without a payload.

Content-format option payload Read on Object Read on Object Instance Read on Resource Instance
none none Error: "Invalid Response: Unable to decode response payload" Error: "Invalid Response: Unable to decode response payload" Error: "Invalid Response: Unable to decode response payload"
SenML CBOR none Success Error: "Invalid Response: Unable to decode response payload" Success
SenML CBOR 0x80 (array of 0 elements) Success Error: "Invalid Response: Unable to decode response payload" Success
SenML JSON none Success Error: "Invalid Response: Unable to decode response payload" Success
SenML JSON "[]" Success Error: "Invalid Response: Unable to decode response payload" Success
TLV none Success Success Success
TLV 0x08 00 00 (empty instance 0) Success Success Success

How to reproduce

No response

Relevant Output

No response

sbernard31 commented 5 months ago

Thx for reporting :pray:.

For none content format line, this is the expected behavior for now. We will wait for OMA answer to https://github.com/OpenMobileAlliance/OMA_LwM2M_for_Developers/issues/579 before to change anything.

For Read on Object Instance, I need to investigate as at first sight there is a kind on inconsistency.

sbernard31 commented 5 months ago

The Object Instance inconsistent behavior is fixed by #1624.

I let this issue open waiting for the none content format case answer.

sbernard31 commented 5 months ago

I integrated #1624 in master. It will be available in sandbox very soon and will be part of next release 2.0.0-M15.

Issue was closed automatically I reopen it because :

I let this issue open waiting for the none content format case answer.

slaft commented 3 months ago

While looking into https://github.com/eclipse-leshan/leshan/issues/1633, I also checked what happens when an empty payload is sent in a Read Response/Observe Response/Notify.

This is what I came across (with Leshan 2.0.0-M15):