Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KVv2 json cursor jumps on "enter" #27569

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Jun 21, 2024

THIS BREAKS all the things. Going another route, stay tuned.

Description

Fixes Issue #27524

It's caused by codemirrors .setValue—see here. Granted, we're on an older version, so here's the setValue we're actually using (I've tested the updated codemirror, it doesn't fix this).

Here's my theory of what's happening:

  1. When someone is using or toggling to the JSON editor for KVv2 when "creating" or "creating a new version" of a secret we parse the json onChange.
  2. This triggers the codemirror-modifier modify function here.
  3. If you hit a value like "enter" (a whitespace value), then the namedArgs.content has been parsed, before the this._editor.getValue() has been. Meaning that for a whitespace value like "enter" we're comparing:
    {foo: 'beep'} vs { "foo": "beep" /n }
    And this is the 🖤 of the problem. So this only happens on whitespace events and on KVv2. I've been over various solutions and think this one is the safest in regards to regressions and backporting. It more or less ensures that we're comparing the same values before hitting setValue.

Note: this only happens to KVv2 because it's the only use case where we mess with the json value onChange. The other JsonEditor instances (policies, cubbyhole, etc) all parse the json value onSave like workflows. It's not an easy fix to do move KVv2 to parse onSave and frankly I'm nervous about causing other regressions in that secret engine by changing a pattern like that. There have been several prs on the json toggle area just for KVv2 for strange behavior. I'm fairly certain the new "Reveal values/masking" on toggle depends on the onChange event as well because it hits this setValue event and updates the values from masked to what they really are.

TODO only if you're a HashiCorp employee

  • Labels: If this PR is the CE portion of an ENT change, and that ENT change is
    getting backported to N-2, use the new style backport/ent/x.x.x+ent labels
    instead of the old style backport/x.x.x labels.
  • Labels: If this PR is a CE only change, it can only be backported to N, so use
    the normal backport/x.x.x label (there should be only 1).
  • ENT Breakage: If this PR either 1) removes a public function OR 2) changes the signature
    of a public function, even if that change is in a CE file, double check that
    applying the patch for this PR to the ENT repo and running tests doesn't
    break any tests. Sometimes ENT only tests rely on public functions in CE
    files.
  • Jira: If this change has an associated Jira, it's referenced either
    in the PR description, commit message, or branch name.
  • RFC: If this change has an associated RFC, please link it in the description.
  • ENT PR: If this change has an associated ENT PR, please link it in the
    description. Also, make sure the changelog is in this PR, not in your ENT PR.

@Monkeychip Monkeychip added ui regression Used to indicate possible regressions between versions backport/1.17.x labels Jun 21, 2024
@Monkeychip Monkeychip added this to the 1.17.1 milestone Jun 21, 2024
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jun 21, 2024
Copy link

CI Results: failed ❌

@noelledaley noelledaley modified the milestones: 1.17.1, 1.17.2 Jun 24, 2024
@Monkeychip Monkeychip marked this pull request as ready for review June 27, 2024 21:12
@Monkeychip Monkeychip requested a review from a team as a code owner June 27, 2024 21:12
Copy link

Build Results:
All builds succeeded! ✅

@Monkeychip Monkeychip added backport/ent/1.15.x+ent Changes are backported to 1.15.x+ent backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent labels Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.15.x+ent Changes are backported to 1.15.x+ent backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.17.x hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed regression Used to indicate possible regressions between versions ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants