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

Update the user with existing name and username. #596

Open
faznan3nazer opened this issue May 17, 2020 · 42 comments · May be fixed by #1159
Open

Update the user with existing name and username. #596

faznan3nazer opened this issue May 17, 2020 · 42 comments · May be fixed by #1159
Assignees
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Status: Available Issue was approved and available to claim or abandoned for over 3 days.
Milestone

Comments

@faznan3nazer
Copy link
Contributor

When you are updating the user with existing name and username, you are getting an error message "A user with that username already exists."
To Reproduce

Steps to reproduce the behavior:

Current username: zxcvbnm
Updating username to: zxcvbnm,
Current name: zxcvbnm
Updating name to: zxcvbnm,

  1. Go to 'User-update user profile'.
  2. Provide the access token.
  3. .{
    "name": "zxcvbnm",
    "username": "zxcvbnm",
    "bio": "string",
    "location": "string",
    "occupation": "string",
    "organization": "string",
    "slack_username": "string",
    "social_media_links": "string",
    "skills": "string",
    "interests": "string",
    "resume_url": "string",
    "photo_url": "string",
    "need_mentoring": true,
    "available_to_mentor": true
    }
  4. Click on 'Execute'.
  5. Scroll down to 'Responses'.

Screenshot (70)

Expected behavior
It should either be successfully updated message or a message like "no fields have been updated". Also the error message being shown now is not listed under responses.

Desktop (please complete the following information):

  • OS: Windows 10
  • Browser chrome
@gaurivn gaurivn added the Category: Coding Changes to code base or refactored code that doesn't fix a bug. label May 17, 2020
@evangelisilva evangelisilva added the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label May 24, 2020
@gaurivn gaurivn added Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. and removed Status: Available Issue was approved and available to claim or abandoned for over 3 days. labels Aug 22, 2020
@gaurivn
Copy link
Member

gaurivn commented Aug 22, 2020

I added the Status: On Hold since I thought of including this issue for the upcoming Open Source Hack.

@gaurivn gaurivn added Open Source Hack Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. and removed Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. labels Aug 23, 2020
@vj-codes vj-codes added Status: Available Issue was approved and available to claim or abandoned for over 3 days. and removed Status: On Hold Issue or PR needs more info, a discussion, a review or approval from a Maintainer/Code Owner. labels Aug 24, 2020
@alapan-sau
Copy link
Contributor

I would like to work on this issue for OSH.

@gaurivn gaurivn removed the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Aug 27, 2020
@gaurivn
Copy link
Member

gaurivn commented Aug 27, 2020

Hi @alapan-sau, this issue will be made available once Open Source Hack starts on September 1st, 2020. Till then you can set up the development environment for and familiarise yourself with mentorship-backend. If you've any doubts feel free to ask them on Zulip.

@alapan-sau
Copy link
Contributor

As OSH is open today, May I work on this issue?

@gaurivn
Copy link
Member

gaurivn commented Aug 31, 2020

As OSH is open today, May I work on this issue?

Hi @alapan-sau, you've already been assigned issue #746, once you're done with sending a PR for the same, you can work on available issues.

@faznan3nazer
Copy link
Contributor Author

I would like to work on this issue... Can you please assign this to me for Open-Source Hack?

@gaurivn
Copy link
Member

gaurivn commented Sep 1, 2020

I would like to work on this issue... Can you please assign this to me for Open-Source Hack?

Sure @faznan3nazer, here you go

@vj-codes
Copy link
Member

vj-codes commented Sep 7, 2020

@faznan3nazer making it available as you are already assigned #606

@vj-codes vj-codes added the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Sep 7, 2020
@pallavisavant
Copy link
Contributor

can i work on this issue ...Thanks.

@vj-codes
Copy link
Member

vj-codes commented Sep 8, 2020

Assigning you @pallavisavant
Happy coding!

@vj-codes vj-codes removed the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Sep 8, 2020
@pallavisavant
Copy link
Contributor

@vj-codes I am facing one issue while reproducing this....we get the access token by giving username and password in login section rgt,and after that we are supposed to use this token for updating ...it shows invalid token wherever i am using it.Can anyone help ..Thanks.

@vj-codes
Copy link
Member

Assigning you @epicadk
Happy coding!

@epicadk
Copy link
Member

epicadk commented Feb 21, 2021

Should I also handle race conditions? @isabelcosta @faznan3nazer

@epicadk epicadk added the Type: Bug Bug or Bug fixes. label Feb 21, 2021
@isabelcosta
Copy link
Member

@epicadk which race conditions?

@epicadk
Copy link
Member

epicadk commented Feb 21, 2021

@epicadk which race conditions?

Currently , we first check if the username is available or not and then proceed to updating it . However this isn't how it should be implemented because what happens when two users try to register with the same username and almost the same time? It would lead to an unexpected error. So we shouldn't query the database to check if the username if available or not but rather just update the username and handle the exception if a user with that username already exists.

@epicadk
Copy link
Member

epicadk commented Feb 21, 2021

@isabelcosta I can't seem to find the link to the resource where I read about this but I can try to explain here. So consider 2 users user1 and user2. Suppose both of them want to ( in this case) change their existing username to the new same username. So what'll happen is first user1's request will check if the username is already taken and it will find that the username does not exist in the database, at the same time user2's request can also query the database to check if the username exists and since user1's data hasn't been updated yet user2 will also find that the username is available. Consider User1's data is now updated however when user2 attempts to update their data an exception will be thrown and the app will crash if this is not handled.

@epicadk
Copy link
Member

epicadk commented Feb 21, 2021

I'm sorry that probably doesn't explain it well enough maybe I can try in the mentorship open session.

@isabelcosta
Copy link
Member

No problem @epicadk we'll discuss in the meeting :)

@epicadk
Copy link
Member

epicadk commented Feb 24, 2021

Actually this is working just fine. The documentation is not clear enough maybe you only have to send the data you want to change. So say you only want to change location from Perth to Sydney then you would only send
{"location" : "Sydney"} and nothing else. Do we want to change this behavior and expect the user to send all fields or should I keep it like this?

@epicadk
Copy link
Member

epicadk commented Feb 26, 2021

Un-assigning myself as the required behavior needs to be discussed before changes are made. The endpoint does what is claims to do. If we do expect all the user data to be present then the documentation needs to be changed as well. Adding this to the mentorship system agenda. cc @isabelcosta

@epicadk epicadk removed their assignment Feb 26, 2021
@epicadk epicadk added Status: Available Issue was approved and available to claim or abandoned for over 3 days. and removed Type: Bug Bug or Bug fixes. labels Feb 26, 2021
@gaurivn gaurivn added this to the 1st MVP milestone Jun 18, 2021
@isabelcosta
Copy link
Member

I think remember this being the issue of PUT vs PATCH 🤔 just putting here so I don't forget later

@diananova
Copy link
Contributor

diananova commented Jul 21, 2021

Can I work on this? @isabelcosta

@devkapilbansal devkapilbansal removed the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Jul 25, 2021
@vj-codes vj-codes added the Status: Available Issue was approved and available to claim or abandoned for over 3 days. label Jan 27, 2022
@hirshrm
Copy link

hirshrm commented Nov 7, 2022

Hi, is anyone working on this? Could I be assigned to work on it if not? @vj-codes

@vj-codes
Copy link
Member

Assigning you @hirshrm
Happy coding!

hirshrm pushed a commit to hirshrm/mentorship-backend that referenced this issue Dec 5, 2022
@hirshrm hirshrm linked a pull request Dec 5, 2022 that will close this issue
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Coding Changes to code base or refactored code that doesn't fix a bug. Status: Available Issue was approved and available to claim or abandoned for over 3 days.
Projects
None yet