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

UI: Decode database connection_url #29114

Merged
merged 8 commits into from
Dec 10, 2024

Conversation

hellobontempo
Copy link
Contributor

@hellobontempo hellobontempo commented Dec 5, 2024

Description

We don't have any enterprise only plugins that I'm aware of, but ran enterprise tests just in case ✅

The API returns the oracle (and postgresql) connection_url encoded, but for the UI to pass around data correctly (for viewing and editing) we need to decode it. While we added a helper a while ago to decode the url for display (#23695), submitting any updates to the connection failed because the form submitted the unencoded connection_url. Now when the request is returned from the server, we interrupt it and decode the uri.

This started failing in 1.16, previous POST requests from 1.15.x show only the updated field being submitted. I suspect during an ember upgrade something changed internally in the model.save() method so now all, changed, model parameters are submitted instead of just the updated values. Submitting all of the form inputs is our current form pattern (unless we’re specifically performing a patch) so I didn't dig into reverting this behavior. Decoding the uri seemed like the more reliable change moving forward.

API response

Screenshot 2024-12-05 at 3 53 09 PM

Failed save

Notice the unencoded url in the Connection URL input
Screenshot 2024-12-05 at 3 55 50 PM

With fix 🔧

Screenshot 2024-12-05 at 3 59 05 PM

TODO only if you're a HashiCorp employee

  • Backport Labels: If this fix needs to be backported, use the appropriate backport/ label that matches the desired release branch. Note that in the CE repo, the latest release branch will look like backport/x.x.x, but older release branches will be backport/ent/x.x.x+ent.
    • LTS: If this fixes a critical security vulnerability or severity 1 bug, it will also need to be backported to the current LTS versions of Vault. To ensure this, use all available enterprise labels.
  • 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.

@hellobontempo hellobontempo added backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/1.18.x backport/ent/1.17.x+ent Changes are backported to 1.17.x+ent labels Dec 5, 2024
@hellobontempo hellobontempo requested a review from a team as a code owner December 5, 2024 23:59
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Dec 6, 2024
Copy link

github-actions bot commented Dec 6, 2024

CI Results:
All Go tests succeeded! ✅

Copy link

github-actions bot commented Dec 6, 2024

Build Results:
All builds succeeded! ✅

@hellobontempo hellobontempo requested a review from a team as a code owner December 6, 2024 00:08
@hellobontempo hellobontempo requested a review from armon December 6, 2024 00:08
@@ -29,6 +29,16 @@ export default RESTSerializer.extend({
...payload.data,
...payload.data.connection_details,
};

// connection_details are spread above into the main body of response so we can remove redundant data
delete response.connection_details;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was some cleanup, but i can remove if folks are worried about regressions. I searched globally for any use of connection_details or connectionDetails related to databases and didn't come across anything.

@@ -337,9 +339,11 @@ module('Acceptance | secrets/database/*', function (hooks) {
await visit('/vault/secrets');
});
}
test('database connection create and edit: vault-plugin-database-oracle', async function (assert) {

// keep oracle as separate test because it relies on an external plugin that isn't rolled into the vault binary
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great comment

Monkeychip
Monkeychip previously approved these changes Dec 6, 2024
Copy link
Contributor

@Monkeychip Monkeychip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great problem solving and fixing!

@hellobontempo hellobontempo added this to the 1.18.3 milestone Dec 6, 2024
@hellobontempo hellobontempo removed the request for review from armon December 6, 2024 18:06
@hellobontempo hellobontempo merged commit 5ba4fb3 into main Dec 10, 2024
33 checks passed
@hellobontempo hellobontempo deleted the ui/fix-oracle-connection-url-decoding branch December 10, 2024 17:31
@hellobontempo hellobontempo modified the milestones: 1.18.3, 1.19.0-rc Dec 10, 2024
@hellobontempo hellobontempo changed the title UI: Decode Oracle database connection_url UI: Decode database connection_url Dec 10, 2024
Monkeychip pushed a commit that referenced this pull request Dec 18, 2024
* decode url in the serializer for oracle connection_url

* add serializer test

* add test for oracle

* add test back, remove decode-url helper

* update comment and test

* link jiras VAULT-32830 VAULT-29785

* add changelog

* add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport/ent/1.16.x+ent Changes are backported to 1.16.x+ent backport/ent/1.17.x+ent Changes are backported to 1.17.x+ent backport/1.18.x hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants