openhab / openhab-webui

Web UIs of openHAB
Eclipse Public License 2.0
224 stars 239 forks source link

Adding custom channels to things does not save when include spaces #876

Closed openPhiL closed 1 year ago

openPhiL commented 3 years ago

The problem

I create a new generic MQTT thing (works with generic HTTP Thing as well) and add custom channels. If the channel identificator has a space, there is no warning/error. I guess it is common knowledge that the identifier cannot be space, but it is not checked. You can save and all.. When you leave the screen and then return back into the thing, the channel is gone. It did "not" save.

I mean this spot here: image

Expected behavior

I expect an error telling me on_save that the channel idenfiticator cannot have spaces in there (and probably other special characters like äöß :.. )

Steps to reproduce

1.Install http or mqtt binding 2.create at thing and name it 3.go to channels 4.create new channel

  1. enter a channel idenfiticator containing a space e.g. "bla bla"
  2. enter all other mandatory information and save.
  3. Press F5 and look at the channels that you just saved.

Your environment

runtimeInfo:
  version: 3.0.0
  buildString: Release Build
locale: de_DE
systemInfo:
  configFolder: /etc/openhab
  userdataFolder: /var/lib/openhab
  logFolder: /var/log/openhab
  javaVersion: 11.0.9.1
  javaVendor: Azul Systems, Inc.
  javaVendorVersion: Zulu11.43+55-CA
  osName: Linux
  osVersion: 5.4.44-1-pve
  osArchitecture: amd64
  availableProcessors: 1
  freeMemory: 36344464
  totalMemory: 173015040
bindings:
  - astro
  - http
  - logreader
  - mqtt
  - network
  - openweathermap
  - shelly
  - telegram
  - velux
clientInfo:
  device:
    ios: false
    android: false
    androidChrome: false
    desktop: true
    iphone: false
    ipod: false
    ipad: false
    edge: false
    ie: false
    firefox: false
    macos: false
    windows: true
    cordova: false
    phonegap: false
    electron: false
    nwjs: false
    webView: false
    webview: false
    standalone: false
    os: windows
    pixelRatio: 1
    prefersColorScheme: light
  isSecureContext: false
  locationbarVisible: true
  menubarVisible: true
  navigator:
    cookieEnabled: true
    deviceMemory: N/A
    hardwareConcurrency: 4
    language: de-DE
    languages:
      - de-DE
      - de
      - en-US
      - en
      - fr
    onLine: true
    platform: Win32
  screen:
    width: 3840
    height: 2160
    colorDepth: 24
  support:
    touch: false
    pointerEvents: true
    observer: true
    passiveListener: true
    gestures: false
    intersectionObserver: true
  themeOptions:
    dark: dark
    filled: true
    pageTransitionAnimation: default
    bars: light
    homeNavbar: default
    homeBackground: default
    expandableCardAnimation: default
  userAgent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML,
    like Gecko) Chrome/88.0.4324.104 Safari/537.36
timestamp: 2021-02-04T21:57:38.978Z

Browser console

Browser network traffic

image

"{\"error\":{\"message\":\"UID segment \\u0027asd asd as d\\u0027 contains invalid characters. The last segment of the channel UID must match the pattern \\u0027[\\\\w-]*|[\\\\w-]*#[\\\\w-]*\\u0027.\",\"http-code\":500,\"exception\":{\"class\":\"java.lang.IllegalArgumentException\",\"message\":\"UID segment \\u0027asd asd as d\\u0027 contains invalid characters. The last segment of the channel UID must match the pattern \\u0027[\\\\w-]*|[\\\\w-]*#[\\\\w-]*\\u0027.\",\"localized-message\":\"UID segment \\u0027asd asd as d\\u0027 contains invalid characters. The last segment of the channel UID must match the pattern \\u0027[\\\\w-]*|[\\\\w-]*#[\\\\w-]*\\u0027.\"}}}"
"{\"error\":{\"message\":\"UID segment \\u0027asd asd as d\\u0027 contains invalid characters. The last segment of the channel UID must match the pattern \\u0027[\\\\w-]*|[\\\\w-]*#[\\\\w-]*\\u0027.\",\"http-code\":500,\"exception\":{\"class\":\"java.lang.IllegalArgumentException\",\"message\":\"UID segment \\u0027asd asd as d\\u0027 contains invalid characters. The last segment of the channel UID must match the pattern \\u0027[\\\\w-]*|[\\\\w-]*#[\\\\w-]*\\u0027.\",\"localized-message\":\"UID segment \\u0027asd asd as d\\u0027 contains invalid characters. The last segment of the channel UID must match the pattern \\u0027[\\\\w-]*|[\\\\w-]*#[\\\\w-]*\\u0027.\"}}}"

Additional information

hubsif commented 3 years ago

This has been fixed in #795 and can be closed.