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

Remove user JSON object wrapper from user/current PUT requests #6396

Closed
tcfdev opened this issue Dec 2, 2021 · 0 comments · Fixed by #6832
Closed

Remove user JSON object wrapper from user/current PUT requests #6396

tcfdev opened this issue Dec 2, 2021 · 0 comments · Fixed by #6832
Labels
improvement The functionality exists but it could be improved in some way. low impact affects only a small portion of a CDN, and cannot itself break one tech debt rework due to choosing easy/limited solution Traffic Ops API Next Improvements to Traffic Ops API - particularly breaking changes

Comments

@tcfdev
Copy link
Collaborator

tcfdev commented Dec 2, 2021

This Improvement request (usability, performance, tech debt, etc.) affects these Traffic Control components:

  • Traffic Clients (go)
  • Traffic Ops
  • Documentation

Current behavior:

The currently logged in user has the ability to edit various fields via a PUT request to the user/current endpoint. However, that request MUST be wrapped in a user JSON object such that the body looks something like:

{
  "user": {
    /* ... */
  }
}

This object appears to be unnecessary, but adds a "gotcha" of sorts to the PUT requests. Even resulting in bug submissions such as #6367

New behavior:

Removing this wrapper will help reduce unnecessary code, reduce and add clarity to documentation, and help with maintainability going forward.

// lib/go-tc/users.go

// CurrentUserUpdateRequest differs from a regular User/UserCurrent in that many of its fields are
// *parsed* but not *unmarshaled*. This allows a handler to distinguish between "null" and
// "undefined" values.
type CurrentUserUpdateRequest struct {
	// User, for whatever reason, contains all of the actual data.
	User CurrentUserUpdateRequestUser `json:"user"` // This is the wrapper
}

Additionally the documentation for the API endpoint will need to be updated to remove the reference to the user wrapper object. docs for user/current

@tcfdev tcfdev added the improvement The functionality exists but it could be improved in some way. label Dec 2, 2021
@ocket8888 ocket8888 added tech debt rework due to choosing easy/limited solution Traffic Ops API Next Improvements to Traffic Ops API - particularly breaking changes labels Dec 2, 2021
@mitchell852 mitchell852 added the low impact affects only a small portion of a CDN, and cannot itself break one label Dec 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement The functionality exists but it could be improved in some way. low impact affects only a small portion of a CDN, and cannot itself break one tech debt rework due to choosing easy/limited solution Traffic Ops API Next Improvements to Traffic Ops API - particularly breaking changes
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants