Skip to content

[UI] Ember Data Migration - API Property Casing#31325

Merged
zofskeez merged 11 commits into
mainfrom
ui/VAULT-37717/api-property-casing
Jul 18, 2025
Merged

[UI] Ember Data Migration - API Property Casing#31325
zofskeez merged 11 commits into
mainfrom
ui/VAULT-37717/api-property-casing

Conversation

@zofskeez
Copy link
Copy Markdown
Contributor

Description

Originally the API client was set up to convert model and param name casing to camelCase. Since most of the references to Ember Data model attributes in the app used this casing, it made for an easier migration at the outset.

It was recently discovered that this poses a problem in certain cases where user defined values (paths for secrets engines or auth methods) are returned as keys in the response from the server and these keys were then being converted to camelCase by the client which incorrectly represents the original value if it contained underscores.

This wasn't a problem with Ember Data since the models contained both the original properties from the server (snake_cased) as well as camelCased versions of the attributes so either could be referenced as needed.

The API client has been updated to preserve the original casing returned from the server and this PR updates any references to camelCased API properties in the app.

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.

PCI review checklist

  • I have documented a clear reason for, and description of, the change I am making.
  • If applicable, I've documented a plan to revert these changes if they require more than reverting the pull request.
  • If applicable, I've documented the impact of any changes to security controls.

Examples of changes to security controls include using new access control methods, adding or removing logging pipelines, etc.

@zofskeez zofskeez added this to the 1.21.0-rc1 milestone Jul 17, 2025
@zofskeez zofskeez added the ui label Jul 17, 2025
@github-actions github-actions Bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jul 17, 2025
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jul 17, 2025

CI Results:
All Go tests succeeded! ✅

@zofskeez zofskeez marked this pull request as ready for review July 17, 2025 20:31
@zofskeez zofskeez requested review from a team as code owners July 17, 2025 20:31
@github-actions
Copy link
Copy Markdown

Build Results:
All builds succeeded! ✅

Comment thread ui/app/services/auth.js
ttl: authData?.lease_duration,
ttl: ttl || authData?.lease_duration,
policies: authData?.policies,
mfaRequirement: authData?.mfa_requirement,
Copy link
Copy Markdown
Contributor

@hellobontempo hellobontempo Jul 17, 2025

Choose a reason for hiding this comment

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

I guess the major difference is previously I spread the auth response in the normalize function (at the top) and then overrode keys with the normalized names.

Mostly because I was concerned there could be additional data returned by the API's login response that I missed during the refactor and didn't have test coverage. For example, there's this num_uses key - I don't think it was used anywhere but wasn't sure if there just wasn't test coverage for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right ya I see what you are saying. Your approach was definitely more future proof and I think something that we could look at in a follow up.

The one issue I see with doing that now is that these properties that are explicitly defined are in camelCase and the remaining properties from the spread would now be snake_case which could be confusing.

Given the thorough test coverage (thanks Claire!) I feel pretty good that the existing functionality is preserved but we should definitely look at ways to continue to improve all of this once we have consistent key casing across the app for API props.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The one issue I see with doing that now is that these properties that are explicitly defined are in camelCase and the remaining properties from the spread would now be snake_case which could be confusing.

☝️ yes exactly! I think that would be confusing.

Yep - sounds good! Thanks for thinking that through with me!

Comment thread ui/package.json
"@babel/core": "7.26.10",
"@hashicorp/design-system-components": "4.18.2",
"@hashicorp/vault-client-typescript": "portal:./api-client",
"@hashicorp/vault-client-typescript": "hashicorp/vault-client-typescript",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

👏 👏 👏 👏


switch (type) {
case 'aws':
return camelCase ? stringArrayToCamelCase(awsKeys) : awsKeys;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

😍

Copy link
Copy Markdown
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

I think not spreading the auth response (and just pulling the mfa_requirement key explicitly) is probably okay. Mostly wanted to call it out to see if you had any thoughts about it.

Thanks for tackling this! Seeing these changes really confirms we made the right decision here 🎉

@zofskeez zofskeez merged commit 8700bec into main Jul 18, 2025
32 checks passed
@zofskeez zofskeez deleted the ui/VAULT-37717/api-property-casing branch July 18, 2025 15:32
Erfankam pushed a commit to Erfankam/vault that referenced this pull request Sep 1, 2025
* updates api client vars to snake_case for custom messages

* updates api client vars to snake_case for tools

* updates api client vars to snake_case for sync

* updates api client vars to snake_case for secrets engine

* updates api client vars to snake_case for auth

* updates api client vars to snake_case for usage

* updates api client dep to point to gh repo

* fixes custom-messages service unit tests

* fixes configure-ssh test

* fixes configure-ssh test...again
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed pr/no-changelog ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants