Make REST endpoints accept more logger name characters - #4983
Conversation
|
Are spaces allowed? I've certainly see users use spaces in logger names inside rules before. |
I haven't added spaces - it could be done if it doesn't cause issues. I simply considered Does anybody have any idea if allowing spaces would be problematic? |
|
I'm converting this to draft temporarily because I discovered one more change that's needed to be able to set the log level for loggers with |
bec80b1 to
97b4186
Compare
|
@rkoshak I'm unsure of how to proceed. Not a lot of feedback to be gotten it seems, I can include space too, I'm just worried that it might have some side effects that I haven't thought about. But, if you're saying that users already use logger names with spaces, that indicates that it doesn't cause a problem. "Normally" logger names are Java class names, which can't contain spaces. Thus, I'm a bit unsure if everything is "made to work" with spaces in the logger names. But, most likely, they are just strings, and the content of the string doesn't really matter to the logging framework. |
|
I can say it doesn't cause a problem to write to the logs. If that works I see no reason why setting the logging level won't work too but I've never done it. But I can confirm people use spaces in logger names, particularly with Rules DSL where the first argument to all log statements is the logger name. I've seen many examples of people including spaces in that first argument. |
97b4186 to
f02694e
Compare
|
Space is now included and working according to my testing. |
Signed-off-by: Ravi Nadahar <nadahar@rediffmail.com>
f02694e to
5a9e155
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR modifies REST endpoint path patterns to allow additional characters in logger names, specifically underscore and hyphen characters. The change enables all loggers in the system to be accessible via the REST API by expanding the allowed character set in both validation patterns and JAX-RS path expressions.
Key Changes:
- Updated regex pattern for logger name validation to include hyphens and spaces
- Modified JAX-RS path patterns to accept underscores, hyphens, and URL-encoded spaces in logger names
- Applied changes consistently across GET, PUT, and DELETE endpoints
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
lsiepel
left a comment
There was a problem hiding this comment.
LGTM. @openhab/core-maintainers
holgerfriedrich
left a comment
There was a problem hiding this comment.
I am wondering why handle the first character differently (or I missed to decode the regex correctly ;-) ).
\w is more restrictive as before (I know, edge case, but . was a valid match before and is now rejected.)
Was this intentional?
Yes, it was intentional because as far as I know, it's not actually a valid logger name if it starts with a |
|
I can just add that the reason two different regexes are in use, is that one of for the URL encoded version and the other is for the "decoded" version. |
holgerfriedrich
left a comment
There was a problem hiding this comment.
You comment is fine for me. I don't see a use case for a logger name starting with . as well.
Maybe we get a bug report for this later on because we missed something 🙈
That's always a possibility 😉 |
This fixes #4946.
Given that both
_and-are otherwise in use as logger names in various places in the system, they should be allowed in the REST endpoints so that all loggers can be accessed via the REST API. This PR makes the necessary changes.