rancher / dashboard

The Rancher UI
https://rancher.com
Apache License 2.0
459 stars 260 forks source link

[BUG] Editing a ConfigMap with `\n` or `\t` in the data field via `edit Config` results in `a line break is expected` error in the UI #9841

Closed altulek closed 6 months ago

altulek commented 1 year ago

Rancher Server Setup

Information about the Cluster

User Information

Describe the bug ConfigMap edit doesn't work properly when you are using "\t" (tabulator) character.

To Reproduce

  1. Create new config map
  2. key: a, value: a a b c <- with tab instead of space
  3. key: b, value:a a b c <- with tab instead of space
  4. save

Result Error: "a line break is expected" Expected Result Saved properly

Screenshots

Zrzut ekranu 2023-10-03 142028

Zrzut ekranu 2023-10-03 142003

Additional context The issue happens when values are saved as string. Rancher adds additional key into first data section.

altulek commented 1 year ago

It happened always when YAML data elements becomes a string. I Can see the same when I use "\r" char.

slickwarren commented 1 year ago

I can't reproduce this on rancher version v2.7.6. Here's what I've tried:

altulek commented 1 year ago

You can try this one:

apiVersion: v1
data:
  a: "a\nb\tc"
  b: "a\nb\tc"
kind: ConfigMap
metadata:
  name: yaml-tab-test

After saving this yaml I can't save it again through "Edit Config". After I chose "Edit Config" -> "Edit as YAML" data section looks like this:

data:
  b: |+a: |+a: "a\nb\tc"
  b: "a\nb\tc"

I think that new line also is necessary to trigger this error.

slickwarren commented 1 year ago

repro steps:

tested on v2.7.6 and v2.8.0-alpha2

altulek commented 1 year ago

Caused by rancher/rancher#7670. Same as in [BUG] configmap formatting breaking on creation/edit rancher/dashboard#10066 It seems that https://github.com/nodeca/js-yaml doesen't work properly.

gaktive commented 11 months ago

Internal reference: SURE-7246

hhstu commented 11 months ago

内部参考:SURE-7246

can we get any help? @gaktive

mohag commented 11 months ago

Also see rancher/dashboard#10067

richard-cox commented 11 months ago

~https://github.com/rancher/dashboard/issues/10067 should be tackled at the same time as this. If it's the same issue can be closed as a duplicate~ Closed instead after reviewing description

richard-cox commented 11 months ago

/backport v2.7.next1

nwmac commented 9 months ago

@rak-phillip Is it possible to write automated tests for this?

rak-phillip commented 9 months ago

@nwmac Of course we can! We wrote tests in both #10179 & #10178 that address this area of dashboard. Are there any specific cases that we would like to see represented here?

nwmac commented 9 months ago

@rak-phillip I'm just looking for tests that test the changes in the PR for this issue - it looks like https://github.com/rancher/dashboard/pull/10168/files# has a unit test - if that is sufficient, then we should move this to QA Review, rather than To Test.

Have we got enough that we don't need any manual test for the fix for this bug?

rak-phillip commented 9 months ago

@nwmac I've moved to QA Review. I think that the test covers in such a way we'll prevent regressions of this type in the future. Behavior should remain unchanged otherwise.

rak-phillip commented 9 months ago

/backport v2.8.next1

izaac commented 8 months ago

Manual validation would complement any automation coverage before closing, let's move to To Test @yonasberhe23

gaktive commented 7 months ago

Since this was tested in 2.7.next1 & 2.8.next1 and marked done, I'll defer to QA whether this needs to be retested or if automation was in fact built up in the other tix.

aalves08 commented 6 months ago

@gaktive @nwmac can SURE-7246 be closed in light of this issue status?

LaoZhang-best commented 5 months ago

this issue closed in 2.7.11, 2.7.12, but this version is non public

richard-cox commented 5 months ago

@LaoZhang-best This specific issue is for 2.9.0 which is the next minor release. It looks like it was also shipped in 2.8.3 which is the current minor release and is available to the community. Patch versions of a previous minor release (2.7) are for rancher prime customers and we would recommend community uses upgrade to the current minor release (2.8)