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

Client doesn't allow you to delete "Single" instance objects. #599

Closed
krisdx opened this issue Oct 22, 2018 · 6 comments
Closed

Client doesn't allow you to delete "Single" instance objects. #599

krisdx opened this issue Oct 22, 2018 · 6 comments
Labels
bug Dysfunctionnal behavior client Impact LWM2M client

Comments

@krisdx
Copy link

krisdx commented Oct 22, 2018

Hi everyone,

When sending a delete request, the Leshan client checks only if the object is Multiple, and if it is - allows you to delete the instance. I think that is a problem, because:

  • I am able to delete all instances for an object that is Multiple and Mandatory. For example, the Server object. If I have one instance, I can delete it without error, and that leaves me without a mandatory Server object. Of course, I can make that validation at my application level, just don't know if that's the idea.

  • I'm not able to delete the instance for an object that is Single and Optional. The client responses with "METHOD_NOT_ALLOWED" error, when you're trying to delete the instance of a Single object, without checking if that object is Optional. For example, the the client allows you to delete all instances of the Access Control object (witch is Optional, but Multiple), and doesn't allow you to delete the Location object (witch is also Optional, but Single).

@sbernard31
Copy link
Contributor

Hi thanks you to reporting this.

Just to be sure, you are talking about DELETE operation from a LWM2M server ? not a LWM2M bootstrap Server ?
(My answers below are based on that)

I am able to delete all instances for an object that is Multiple and Mandatory

I'm not sure this is an issue.

Looking at the specification
(§D.1)
"Mandatory: if this field is “Mandatory”, then the LwM2M Client MUST support this Object. If this field
is “Optional”, then the LwM2M Client SHOULD support this Object."

I understand "the object must be supported" as "object should be present but it could have no instances".

(§ 5.7) :
"The “Delete” operation is used for LwM2M Server to delete an Object Instance within the LwM2M Client. The Object Instance that is deleted in the LwM2M Client by the LwM2M Server MUST be an Object Instance that is announced by the LwM2M Client to the LwM2M Server using the “Register” and “Update” operations of the Client Registration Interface. The only exception concerns the single Instance of the mandatory Device Object (ID:3) which SHALL NOT be affected by any Delete operation"

This seems to confirms that mandatory does not means must not be deleted.

For example, the Server object. If I have one instance, I can delete it without error, and that leaves me without a mandatory Server object.

I can see the issue but the spec seems to say that we can delete it 😕

So concretely what does it means :

  1. If we have a bootstrap server configured and only 1 LWM2M Server : If you delete, we should probably bootstrap again.
  2. if we have a bootstrap server configured and several LWM2M Servers : We should use ACL and so this should be difficult to delete everything. If for any reason this happen we should probably bootstrap again. (Leshan client does not support several server for now : Support multi-servers at client side. #600)
  3. No bootstrap server configured and 1 LwM2M server : I don't know what we should do maybe by default we should not allowed to delete the server..
  4. No bootstrap server configured and several LwM2M server : ACL should avoid the issue. I don't know if we should handle the case where the last server try to delete itself like for 3.

I'm not able to delete the instance for an object that is Single and Optional.

I think this is an issue, we should fix this. Re-reading the specification I think we should be able to delete any instance except for device 3.

WDYT ?

@sbernard31 sbernard31 added bug Dysfunctionnal behavior client Impact LWM2M client labels Oct 23, 2018
@krisdx
Copy link
Author

krisdx commented Oct 24, 2018

Yes, I'm talking about the DELETE operation in the Device Management Interface.

You're completely right. After checking again Appendix D.1, the "Mandatory" field's description - it's a field for mandatory support of that object, not for mandatory existence of that object (as I thought...). I've probably got confused with the "Instances" field's description, where they use the "Mandatory" field in the sense of mandatory existence.

And looking at the "Instances" field's description again, it says it all:
"Instances: indicates whether this Object supports multiple Object Instances or not. If this field is “Multiple” then the number of Object Instance can be from 0 to many. If this field is “Single” then the number of Object Instance can be from 0 to 1. If the Object field “Mandatory” is “Mandatory” and the Object field “Instances” is “Single” then, the number of Object Instance MUST be 1."

This completely agrees with your last statement as well. The only MUST existing object instances in the client, have to be Single and Mandatory objects - currently, that's only the Device object. And it's explicitly stated that he MUST NOT be affected by a DELETE operation. This means that every other object instance can be non-existent in the client, and can get deleted. So, for your points about the Server object (bootstrap/no bootstrap and one/several LwM2M server) - after the specification doesn't forbid us to delete, I don't think we should (where ACL allows us to delete, of course).

So yes, the only real issue here is that the client doesn't allow you to delete "Single" instance objects.

@krisdx krisdx changed the title Client only checks if the object is Multiple, on Delete operation Client doesn't allow you to delete "Single" instance objects. Oct 24, 2018
@sbernard31
Copy link
Contributor

So, for your points about the Server object (bootstrap/no bootstrap and one/several LwM2M server) - after the specification doesn't forbid us to delete, I don't think we should (where ACL allows us to delete, of course)

I agree that the specification say nothing about this, but if we have not bootstrap server configuration and we delete the last server instance, we just brick our Leshan client. It sounds not a so good idea... 😕

So yes, the only real issue here is that the client doesn't allow you to delete "Single" instance objects.

I plan to fix it by just forbidding object 3 deletion. This could maybe also make sense to let user being able to make an instance "undeletable".

@sbernard31
Copy link
Contributor

I finally found time to fix this bug.
Could you have look at #614 ?

@krisdx
Copy link
Author

krisdx commented Nov 12, 2018

Yes, it looks fixed.

@sbernard31
Copy link
Contributor

(fixed in master, thx to reporting this !)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Dysfunctionnal behavior client Impact LWM2M client
Projects
None yet
Development

No branches or pull requests

2 participants