← Back to team overview

yahoo-eng-team team mailing list archive

[Bug 2114951] [NEW] device_name does not match '^[a-zA-Z0-9._-r/]*$'

 

Public bug reported:

```shell
# os server create --flavor 4c8g \
--volume mkwinimage-system \
--block-device source_type=image,volume_size=10,uuid=fda4a213-fe0d-43ae-91ef-334abbd2f449,device_type=cdrom,device_name=mkwinimage-cdrom,boot_index=1 \
--block-device source_type=image,volume_size=1,uuid=9b52ddcc-e986-4131-90da-377b4b7a1483,device_type=cdrom,device_name=mkwinimage-virtio \
--nic net-id=d0f6e050-1eb5-496d-9e67-936362d5e617 \
mkwinimage


Invalid input for field/attribute device_name. Value: mkwinimage-cdrom. 'mkwinimage-cdrom' does not match '^[a-zA-Z0-9._-r/]*$' (HTTP 400) (Request-ID: req-3375f296-53b6-462c-8387-391bfc3e0b81)
```


idk what's `_-r`, leaking of escape to - and having unexpected 'r'?

Fixed with tested:


```
>From 47930d2735821410da4387a45264b8a48f771937 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=88=98=E9=A1=BA=E9=92=B0?= <shunyu.liu@xxxxxxxxxxx>
Date: Thu, 19 Jun 2025 11:18:32 +0800
Subject: [PATCH] api: fix device_name pattern in block_device

---
 nova/api/openstack/compute/schemas/servers.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nova/api/openstack/compute/schemas/servers.py b/nova/api/openstack/compute/schemas/servers.py
index 38e88cc6e3..fe53d8c078 100644
--- a/nova/api/openstack/compute/schemas/servers.py
+++ b/nova/api/openstack/compute/schemas/servers.py
@@ -31,7 +31,7 @@ _legacy_block_device_mapping = {
         # containing spaces(defined in nova/block_device.py:from_api())
         'device_name': {
             'type': 'string', 'minLength': 1, 'maxLength': 255,
-            'pattern': '^[a-zA-Z0-9._-r/]*$',
+            'pattern': '^[a-zA-Z0-9._\-/]*$',
         },
         # Defined as boolean in nova/block_device.py:from_api()
         'delete_on_termination': parameter_types.boolean,
-- 
2.43.0
```

testcase:

```
azAZ/.-_059
```

** Affects: nova
     Importance: Undecided
         Status: New

-- 
You received this bug notification because you are a member of Yahoo!
Engineering Team, which is subscribed to OpenStack Compute (nova).
https://bugs.launchpad.net/bugs/2114951

Title:
  device_name does not match '^[a-zA-Z0-9._-r/]*$'

Status in OpenStack Compute (nova):
  New

Bug description:
  ```shell
  # os server create --flavor 4c8g \
  --volume mkwinimage-system \
  --block-device source_type=image,volume_size=10,uuid=fda4a213-fe0d-43ae-91ef-334abbd2f449,device_type=cdrom,device_name=mkwinimage-cdrom,boot_index=1 \
  --block-device source_type=image,volume_size=1,uuid=9b52ddcc-e986-4131-90da-377b4b7a1483,device_type=cdrom,device_name=mkwinimage-virtio \
  --nic net-id=d0f6e050-1eb5-496d-9e67-936362d5e617 \
  mkwinimage

  
  Invalid input for field/attribute device_name. Value: mkwinimage-cdrom. 'mkwinimage-cdrom' does not match '^[a-zA-Z0-9._-r/]*$' (HTTP 400) (Request-ID: req-3375f296-53b6-462c-8387-391bfc3e0b81)
  ```

  
  idk what's `_-r`, leaking of escape to - and having unexpected 'r'?

  Fixed with tested:

  
  ```
  From 47930d2735821410da4387a45264b8a48f771937 Mon Sep 17 00:00:00 2001
  From: =?UTF-8?q?=E5=88=98=E9=A1=BA=E9=92=B0?= <shunyu.liu@xxxxxxxxxxx>
  Date: Thu, 19 Jun 2025 11:18:32 +0800
  Subject: [PATCH] api: fix device_name pattern in block_device

  ---
   nova/api/openstack/compute/schemas/servers.py | 2 +-
   1 file changed, 1 insertion(+), 1 deletion(-)

  diff --git a/nova/api/openstack/compute/schemas/servers.py b/nova/api/openstack/compute/schemas/servers.py
  index 38e88cc6e3..fe53d8c078 100644
  --- a/nova/api/openstack/compute/schemas/servers.py
  +++ b/nova/api/openstack/compute/schemas/servers.py
  @@ -31,7 +31,7 @@ _legacy_block_device_mapping = {
           # containing spaces(defined in nova/block_device.py:from_api())
           'device_name': {
               'type': 'string', 'minLength': 1, 'maxLength': 255,
  -            'pattern': '^[a-zA-Z0-9._-r/]*$',
  +            'pattern': '^[a-zA-Z0-9._\-/]*$',
           },
           # Defined as boolean in nova/block_device.py:from_api()
           'delete_on_termination': parameter_types.boolean,
  -- 
  2.43.0
  ```

  testcase:

  ```
  azAZ/.-_059
  ```

To manage notifications about this bug go to:
https://bugs.launchpad.net/nova/+bug/2114951/+subscriptions