Creating snapshot failed by schema validation when its description contains new line control character

Bug #2021909 reported by Keigo Noha
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Cinder
In Progress
High
Unassigned

Bug Description

This issue is originally reported at downstream in Red Hat.

Summary:
Creating snapshot failed by schema validation when its description contains new line control character.

Details:
The sample output is
~~~
$ openstack volume snapshot create --volume cirros_boot --description "test with new line
character for snapshot volume" test_snapshot
Invalid input for field/attribute description. Value: test with new line
character for snapshot volume. 'test with new line\ncharacter for snapshot volume' does not match '^[\\ -\\~\\\xa0-\\¬\\®-\\ͷ\\ͺ-\\Ϳ\\΄-\\Ί\\Ό\\Ύ-\\Ρ\\Σ-\\ԯ\\Ա-\\Ֆ\\ՙ-\\՟\\ա-\\և\\։-\\֊\\֍-\\֏\\֑-\\ׇ\\א-\\ת\\װ-\\״\\؆-\\؛\\؞-\\ۜ\\۞-\\܍\\ܐ-\\݊\\ݍ-\\ޱ\\߀-\\ߺ\\ࠀ-\\࠭\\࠰-\\࠾\\ࡀ-\\࡛\\࡞\\ࢠ-\\ࢴ\\ࢶ-\\ࢽ\\ࣔ-\\࣡\\ࣣ-\\ঃ\\অ-\\ঌ\\এ-\\ঐ\\ও-\\ন\\প-\\র\\ল\\শ-\\হ\\়-\\ৄ\\ে-\\ৈ\\ো-\\ৎ\\ৗ\\ড়-\\ঢ়\\য়-\\ৣ\\০-\\৻\\ਁ-\\ਃ\\ਅ-\\ਊ\\ਏ-\\ਐ\\ਓ-\\ਨ\\ਪ-\\ਰ\\ਲ-\\ਲ਼\\ਵ-\\ਸ਼\\ਸ-\\ਹ\\਼\\ਾ-\\ੂ\\ੇ-\\ੈ\\ੋ-\\੍\\ੑ\\ਖ਼-\\ੜ\\ਫ਼\\੦-\\ੵ\\ઁ-\\ઃ\\અ-\\ઍ\\એ-\\ઑ\\ઓ-\\ન\\પ-\\ર\\લ-\\ળ\\વ-\\હ\\઼-\\ૅ\\ે-\\ૉ\\ો-\\્\\ૐ\\ૠ-\\ૣ\\૦-\\૱\\ૹ\\ଁ-\\ଃ\\ଅ-\\ଌ\\ଏ-\\ଐ\\ଓ-\\ନ\\ପ-\\ର\\ଲ-\\ଳ\\ଵ-\\ହ\\଼-\\ୄ\\େ-\\ୈ\\ୋ-\\୍\\ୖ-\\ୗ\\ଡ଼-\\ଢ଼\\ୟ-\\ୣ\\୦-\\୷\\ஂ-\\ஃ\\அ-\\ஊ\\எ-\\ஐ\\ஒ-\\க\\ங-\\ச\\ஜ\\ஞ-\\ட\\ண-\\த\\ந-\\ப\\ம-\\ஹ\\ா-\\ூ\\ெ-\\ை\\ொ-\\்\\ௐ\\ௗ\\௦-\\௺\\ఀ-\\ః\\అ-\\ఌ\\ఎ-\\ఐ\\ఒ-\\న\\ప-\\హ\\ఽ-\\ౄ\\ె-\\ై\\ొ-\\్\\ౕ-\\ౖ\\ౘ-\\ౚ\\ౠ-\\ౣ\\౦-\\౯\\౸-\\ಃ\\ಅ-\\ಌ\\ಎ-\\ಐ\\ಒ-\\ನ\\ಪ-\\ಳ\\ವ-\\ಹ\\಼-\\ೄ\\ೆ-\\ೈ\\ೊ-\\್\\ೕ-\\ೖ\\ೞ\\ೠ-\\ೣ\\೦-\\೯\\ೱ-\\ೲ\\ഁ-\\ഃ\\അ-\\ഌ\\എ-\\ഐ\\ഒ-\\ഺ\\ഽ-\\ൄ\\െ-\\ൈ\\ൊ-\\൏\\ൔ-\\ൣ\\൦-\\ൿ\\ං-\\ඃ\\අ-\\ඖ\\ක-\\න\\ඳ-\\ර\\ල\\ව-\\ෆ\\්\\ා-\\ු\\ූ\\ෘ-\\ෟ\\෦-\\෯\\ෲ-\\෴\\ก-\\ฺ\\฿-\\๛\\ກ-\\ຂ\\ຄ\\ງ-\\ຈ\\ຊ\\ຍ\\ດ-\\ທ\\ນ-\\ຟ\\ມ-\\ຣ\\ລ\\ວ\\ສ-\\ຫ\\ອ-\\ູ\\ົ-\\ຽ\\ເ-\\ໄ\\ໆ\\່-\\ໍ\\໐-\\໙\\ໜ-\\ໟ\\ༀ-\\ཇ\\ཉ-\\ཬ\\ཱ-\\ྗ\\ྙ-\\ྼ\\྾-\\࿌\\࿎-\\࿚\\က-\\Ⴥ\\Ⴧ\\Ⴭ\\ა-\\ቈ\\ቊ-\\ቍ\\ቐ-\\ቖ\\ቘ\\ቚ-\\ቝ\\በ-\\ኈ\\ኊ-\\ኍ\\ነ-\\ኰ\\ኲ-\\ኵ\\ኸ-\\ኾ\\ዀ\\ዂ-\\ዅ\\ወ-\\ዖ\\ዘ-\\ጐ\\ጒ-\\ጕ\\ጘ-\\ፚ\\፝-\\፼\\ᎀ-\\᎙\\Ꭰ-\\Ᏽ\\ᏸ-\\ᏽ\\᐀-\\᚜\\ᚠ-\\ᛸ\\ᜀ-\\ᜌ\\ᜎ-\\᜔\\ᜠ-\\᜶\\ᝀ-\\ᝓ\\ᝠ-\\ᝬ\\ᝮ-\\ᝰ\\ᝲ-\\ᝳ\\ក-\\៝\\០-\\៩\\៰-\\៹\\᠀-\\᠍\\᠐-\\᠙\\ᠠ-\\ᡷ\\ᢀ-\\ᢪ\\ᢰ-\\ᣵ\\ᤀ-\\ᤞ\\ᤠ-\\ᤫ\\ᤰ-\\᤻\\᥀\\᥄-\\ᥭ\\ᥰ-\\ᥴ\\ᦀ-\\ᦫ\\ᦰ-\\ᧉ\\᧐-\\᧚\\᧞-\\ᨛ\\᨞-\\ᩞ\\᩠-\\᩼\\᩿-\\᪉\\᪐-\\᪙\\᪠-\\᪭\\᪰-\\᪾\\ᬀ-\\ᭋ\\᭐-\\᭼\\ᮀ-\\᯳\\᯼-\\᰷\\᰻-\\᱉\\ᱍ-\\ᲈ\\᳀-\\᳇\\᳐-\\ᳶ\\᳸-\\᳹\\ᴀ-\\᷵\\᷻-\\ἕ\\Ἐ-\\Ἕ\\ἠ-\\ὅ\\Ὀ-\\Ὅ\\ὐ-\\ὗ\\Ὑ\\Ὓ\\Ὕ\\Ὗ-\\ώ\\ᾀ-\\ᾴ\\ᾶ-\\ῄ\\ῆ-\\ΐ\\ῖ-\\Ί\\῝-\\`\\ῲ-\\ῴ\\ῶ-\\῾\\\u2000-\\\u200a\\‐-\\‧\\\u202f-\\\u205f\\⁰-\\ⁱ\\⁴-\\₎\\ₐ-\\ₜ\\₠-\\₾\\⃐-\\⃰\\℀-\\↋\\←-\\⏾\\␀-\\␦\\⑀-\\⑊\\①-\\⭳\\⭶-\\⮕\\⮘-\\⮹\\⮽-\\⯈\\⯊-\\⯑\\⯬-\\⯯\\Ⰰ-\\Ⱞ\\ⰰ-\\ⱞ\\Ⱡ-\\ⳳ\\⳹-\\ⴥ\\ⴧ\\ⴭ\\ⴰ-\\ⵧ\\ⵯ-\\⵰\\⵿-\\ⶖ\\ⶠ-\\ⶦ\\ⶨ-\\ⶮ\\ⶰ-\\ⶶ\\ⶸ-\\ⶾ\\ⷀ-\\ⷆ\\ⷈ-\\ⷎ\\ⷐ-\\ⷖ\\ⷘ-\\ⷞ\\ⷠ-\\⹄\\⺀-\\⺙\\⺛-\\⻳\\⼀-\\⿕\\⿰-\\⿻\\\u3000-\\〿\\ぁ-\\ゖ\\゙-\\ヿ\\ㄅ-\\ㄭ\\ㄱ-\\ㆎ\\㆐-\\ㆺ\\㇀-\\㇣\\ㇰ-\\㈞\\㈠-\\㋾\\㌀-\\䶵\\䷀-\\鿕\\ꀀ-\\ꒌ\\꒐-\\꓆\\ꓐ-\\ꘫ\\Ꙁ-\\꛷\\꜀-\\Ɪ\\Ʞ-\\ꞷ\\ꟷ-\\꠫\\꠰-\\꠹\\ꡀ-\\꡷\\ꢀ-\\ꣅ\\꣎-\\꣙\\꣠-\\ꣽ\\꤀-\\꥓\\꥟-\\ꥼ\\ꦀ-\\꧍\\ꧏ-\\꧙\\꧞-\\ꧾ\\ꨀ-\\ꨶ\\ꩀ-\\ꩍ\\꩐-\\꩙\\꩜-\\ꫂ\\ꫛ-\\꫶\\ꬁ-\\ꬆ\\ꬉ-\\ꬎ\\ꬑ-\\ꬖ\\ꬠ-\\ꬦ\\ꬨ-\\ꬮ\\ꬰ-\\ꭥ\\ꭰ-\\꯭\\꯰-\\꯹\\가-\\힣\\ힰ-\\ퟆ\\ퟋ-\\ퟻ\\豈-\\舘\\並-\\龎\\ff-\\st\\ﬓ-\\ﬗ\\יִ-\\זּ\\טּ-\\לּ\\מּ\\נּ-\\סּ\\ףּ-\\פּ\\צּ-\\﯁\\ﯓ-\\﴿\\ﵐ-\\ﶏ\\ﶒ-\\ﷇ\\ﷰ-\\﷽\\︀-\\︙\\︠-\\﹒\\﹔-\\﹦\\﹨-\\﹫\\ﹰ-\\ﹴ\\ﹶ-\\ﻼ\\!-\\ᄒ\\ᅡ-\\ᅦ\\ᅧ-\\ᅬ\\ᅭ-\\ᅲ\\ᅳ-\\ᅵ\\¢-\\₩\\│-\\○\\-\\�]*$' (HTTP 400) (Request-ID: req-XXX)
~~~

The same description doesn't cause a failure on volume creation operation.

Version-Release number of selected component (if applicable):
Current upstream and downstream cinder.

How reproducible:
Everytime when a user run the command.

Steps to Reproduce:
1. Create a volume.
2. Create a snapshot with the description which contains a new line character like
~~~
$ openstack volume snapshot create --volume cirros_boot --description "test with new line <press enter key to insert the new line character>
character for snapshot volume" test_snapshot
~~~

Actual results:
The request is failed as HTTP Code:400.

Expected results:
The request is succeeded like a volume creation.

Additional info:
In my preliminary research, the difference between volume creation and snapshot creation comes from the schema validation.

For volume creation, the schema validation is specified as
~~~
create = {
    'type': 'object',
    'properties': {
        'volume': {
            'type': 'object',
            'properties': {
                'name': {'type': ['string', 'null'],
                         'format': 'name_non_mandatory_remove_white_spaces'},
                'description': {
                    'type': ['string', 'null'],
                    'format': 'description_non_mandatory_remove_white_spaces'},
                'display_name': {
                    'type': ['string', 'null'],
                    'format': 'name_non_mandatory_remove_white_spaces'},
                'display_description': {
                    'type': ['string', 'null'],
                    'format':
                        'description_non_mandatory_remove_white_spaces'},
:
}
~~~

On the other hand, the schema validation for snapshot is defined as
~~~
valid_description_regex_base = '^[%s]*$'

valid_description_regex = valid_description_regex_base % (
    _build_regex_range())

description = {
    'type': ['string', 'null'], 'minLength': 0, 'maxLength': 255,
    'pattern': valid_description_regex,
}

create = {
    'type': 'object',
    'properties': {
        'type': 'object',
        'snapshot': {
            'type': 'object',
            'properties': {
                'name': parameter_types.name_allow_zero_min_length,
                'display_name': parameter_types.name_allow_zero_min_length,
                'description': parameter_types.description,
                'volume_id': parameter_types.uuid_allow_null,
                'force': parameter_types.boolean,
                'metadata': parameter_types.metadata_allows_null,
            },
            'required': ['volume_id'],
            'additionalProperties': False,
        },
    },
    'required': ['snapshot'],
    'additionalProperties': False,
}
~~~

In cinder, description field for volume and snapshot are defined as the same data type,
~~~
class Volume(cleanable.CinderCleanableObject, base.CinderObject,
             base.CinderObjectDictCompat, base.CinderComparableObject,
             base.ClusteredObject):
:
    fields = {

        'display_description': fields.StringField(nullable=True),
~~~

~~~
class Snapshot(cleanable.CinderCleanableObject, base.CinderObject,
               base.CinderObjectDictCompat, base.CinderComparableObject,
               base.ClusteredObject):
:
    fields = {
:
        'display_description': fields.StringField(nullable=True),
~~~

In my opinion, there is no obvious reason why we implement the different validation methods between volume and snapshot for description field.

Tags: snapshot
Revision history for this message
Sofia Enriquez (lsofia-enriquez) wrote :

Hi Keigo Noha,

- Do you have the RED HAT bugzilla link?
- What cinder volume backend are you using?

Thanks and Cheers

tags: added: snapshot
Changed in cinder:
importance: Undecided → Medium
Revision history for this message
Keigo Noha (knoha) wrote :

Hi Sofia,

The link to Red Hat private bugzilla is https://bugzilla.redhat.com/show_bug.cgi?id=2210621.
I can reproduce the issue with lvm backend.
From my investigation, the issue looks independent from the backend type.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to cinder (master)

Fix proposed to branch: master
Review: https://review.opendev.org/c/openstack/cinder/+/884958

Changed in cinder:
status: New → In Progress
Revision history for this message
Sofia Enriquez (lsofia-enriquez) wrote :

This bug was discussed on May 31, 2023. You can refer to the discussion here: https://meetings.opendev.org/meetings/cinder_bs/2023/cinder_bs.2023-05-31-15.03.log.html#l-31

Changed in cinder:
importance: Medium → High
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.