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

Conflict Write(Update)/Execute again ? #527

Closed
sbernard31 opened this issue May 26, 2021 · 5 comments
Closed

Conflict Write(Update)/Execute again ? #527

sbernard31 opened this issue May 26, 2021 · 5 comments

Comments

@sbernard31
Copy link

Answering to #526, I just see that at least since LWM2M 1.2 (transport§6-4-4-Device-Management-and-Service-Enablement-Interface) POST on /{Object ID}/{Object Instance ID}/{Resource ID} have several meaning.
So, a client must know the model to be able to interpret it.

I'm not totally sure if allowing POST for partial write on resource was done on purpose because the spec is a bit contradictory :
It seems to alllow it here :

Operation CoAP Method and Content Formats Path
Write (Replace) PUT Content Format: see [LwM2M-CORE] /{Object ID}/{Object Instance ID}
/{Object ID}/{Object Instance ID}/{Resource ID}
/{Object ID}/{Object Instance ID}/{Resource ID}/{Resource Instance ID}
Write (Partial Update) POST Content Format: see [LwM2M-CORE] /{Object ID}/{Object Instance ID}
/{Object ID}/{Object Instance ID}/{Resource ID} only for Multiple-Instance Resources

but not there :

An Object Instance, a Resource or a Resource Instance are written by sending a CoAP PUT request to the corresponding path. The request includes the value to be written in the corresponding Plain Text, Opaque, TLV, LwM2M CBOR, SenML CBOR, or SenML JSON format according to the Content-Format option which MUST be specified [CoAP]. In addition, an Object Instance can be written by sending a CoAP POST request; in that case the specified Content-Format MUST be one of the TLV, LwM2M CBOR, SenML CBOR or SenML JSON formats. CoAP PUT is used for Replace. CoAP POST or CoAP iPatch is used for Partial Update.

(meaning POST is only for Object Instance)

A similar problem was raised several years ago(see #29). It was considered as an issue and fixed.
This new addition reintroduce this kind of problem.

@hannestschofenig
Copy link

Thanks for spotting this issue. We will clarify the sentence in the v1.2.1 bugfix release.

@sbernard31
Copy link
Author

I'm not sure I was clear but the real issue for me is more that a POST on /{Object ID}/{Object Instance ID}/{Resource ID} could be an EXECUTE or a PARTIAL WRITE.

Operation CoAP Method and Content Formats Path
Write (Partial Update) POST Content Format: see [LwM2M-CORE] /{Object ID}/{Object Instance ID} /{Object ID}/{Object Instance ID}/{Resource ID} only for Multiple-Instance Resources
Execute POST Content Format: none, or text/plain (see [LwM2M-CORE]) /{Object ID}/{Object Instance ID}/{Resource ID}

Meaning that implementation need to know the model to understand it.
This was considered as a bad idea previously (see #29).

@dnav
Copy link
Member

dnav commented Jun 11, 2021

When receiving a POST on /{Object ID}/{Object Instance ID}/{Resource ID}, the algorithm is:

  • if the resource is executable then this is an Execute operation
  • if the resource is writable and multiple, then this is a Write (Partial Update) operation
  • else the operation is not allowed

So yes the implementation needs to know the list of allowed operations, and the multiplicity or not of the targeted resource. But this information is present in the implementation anyway.

Another possibility: the format of the payload can be used to determine if the POST is an Execute or a Write (Partial Update) operation:

  • an Execute has no payload or a text/plain payload
  • a Write (Partial Update) uses TLV, SenML CBOR, SenML JSON, or LwM2M CBOR (as the payload must contain the Resource Instance information).

@sbernard31
Copy link
Author

So yes the implementation needs to know the list of allowed operations, and the multiplicity or not of the targeted resource. But this information is present in the implementation anyway.

My point is that was not considered as a such good idea by the past : #29 (comment)

Another possibility: the format of the payload can be used to determine if the POST is an Execute or a Write (Partial Update) operation:

This can do the tricks, thanks for sharing the idea 🙏
Hoping a new feature will not break this tricks.

@mkgillmore
Copy link

Group agrees that this issue is resolved and can be closed 10/31/2023

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

No branches or pull requests

4 participants