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

Resources with no defined operations MUST NOT be considered as executable #1441

Closed
Warmek opened this issue Apr 24, 2023 · 9 comments
Closed
Labels
bug Dysfunctionnal behavior demo Impact our demo (not libraries) server Impact LWM2M server

Comments

@Warmek
Copy link
Contributor

Warmek commented Apr 24, 2023

Question

Should resources with no defined operations be defined as executable in leshan server demo? For example, resource 13 in 1-1_1.xml don't have any operation defined but in leshan server demo it's displayed as executable.

@Warmek Warmek added the question Any question about leshan label Apr 24, 2023
@sbernard31
Copy link
Contributor

Should resources with no defined operations be defined as executable in leshan server demo?

Nope, this is a bug.

@Warmek
Copy link
Contributor Author

Warmek commented Apr 28, 2023

I want to fix it. Where should I start looking for assigning label for this button?

@sbernard31
Copy link
Contributor

Just to be sure we are talking about master ? (not 1.x branch ?)

@sbernard31
Copy link
Contributor

If this is about master.
I take a look at what is sent by the REST API by using my browser developer Tools.
And I see for resource 13 :

{
	"13": {
		"id": 13,
		"name": "Registration Priority Order",
		"operations": "NONE",
		"instancetype": "single",
		"mandatory": false,
		"type": "unsigned_integer",
		"range": "",
		"units": "",
		"description": "The LwM2M Client sequences the LwM2M Server registrations in increasing order of this value. If this value is not defined, registration attempts to this server are not impacted by other server registrations."
	}
}

And looking at :
https://github.com/eclipse/leshan/blob/d5052f181918af3680eb42a7428810a8fb65bcdd/leshan-server-demo/webapp/src/components/resources/ResourceControl.vue#L40-L45

and :
https://github.com/eclipse/leshan/blob/d5052f181918af3680eb42a7428810a8fb65bcdd/leshan-server-demo/webapp/src/components/resources/ResourceControl.vue#L95-L97

It seems that returning NONE or checking String contains E is not a good idea ?
I don't know what is the best move...
Maybe returning empty String instead of NONE ?
Or check that operation is strictly equals to E ? using includes make sense for R or W but not for E
See : https://github.com/eclipse/leshan/blob/d5052f181918af3680eb42a7428810a8fb65bcdd/leshan-core/src/main/java/org/eclipse/leshan/core/model/ResourceModel.java#L26-L40

@Warmek
Copy link
Contributor Author

Warmek commented Apr 28, 2023

I've created a fix on opl/EXEButton.
I went with strictly comparing operation to "E" as I feel like switching from NONE to empty string could be confusing when debugging some issues.
To future-proof from similar issues we could change Operation "NONE" to "none" so it would be possible to have any possible combination of operations, but it seems redundant

@sbernard31
Copy link
Contributor

I went with strictly comparing operation to "E" as I feel like switching from NONE to empty string could be confusing when debugging some issues.

I also feel this is the best way. 🙂

You can create a PR.

@Warmek
Copy link
Contributor Author

Warmek commented Apr 28, 2023

I've created a PR

@sbernard31 sbernard31 changed the title Should resources with no defined operations be defined as executable? Resources with no defined operations MUST NOT be considered as executable Apr 28, 2023
@sbernard31 sbernard31 added bug Dysfunctionnal behavior server Impact LWM2M server demo Impact our demo (not libraries) and removed question Any question about leshan labels Apr 28, 2023
@sbernard31
Copy link
Contributor

Fixed in master. (see #1442)

@sbernard31
Copy link
Contributor

Thx @Warmek 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Dysfunctionnal behavior demo Impact our demo (not libraries) server Impact LWM2M server
Projects
None yet
Development

No branches or pull requests

2 participants