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

The API endpoint /project/validate?projectName=xxxx searches by project key instead of project name #698

Open
jafarre-bi opened this issue Oct 15, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jafarre-bi
Copy link

jafarre-bi commented Oct 15, 2021

Describe the bug
When calling the API endpoint /project/validate?projectName=xxxx, the project is searched by key and not by name.
The behaviour is exactly the same as that of the endpoint /project/key/validate?projectKey=xxxx

To Reproduce
Please recall that this endpoint's functionality is checking whether the specified project name is available (no project exists with that name). In case the name is available, a 200 status code should be returned. In case a project with that name already exists, a 406 status code should be returned.

Steps to reproduce the behavior:

  1. Login into de prov app using a browser
  2. In the browser, enter the endpoint /api/v2/project/validate?projectName=xxxx using an existing project key which is not also a project name.
  3. A 406 status response is received with an XML body with the error message "A project with this name exists". This is mistaken: a project with that key exists, but not with that name.
  4. Enter the endpoint /api/v2/project/validate?projectName=xxxx using an existing project name which is not also a project key.
  5. A 200 status response is received and the browser shows a blank screen. This is mistaken: a project with that name already exists.

Expected behavior
3. No project with the given name is found. A 200 status response is received and the browser shows a blank screen.
5. A project with the given name is found. A 406 status response is received with an XML body with the error message "A project with this name exists".

Screenshots
In the following example, TMEDP is the key of an existing project, but no project with name TMEDP exists.
image

Affected version (please complete the following information):

  • OpenShift: 3.11
  • OpenDevStack 1.1, 1.2
@jafarre-bi jafarre-bi added the bug Something isn't working label Oct 15, 2021
@stitakis
Copy link
Member

@jafarre-viewnext I can't fully understand the problem here, can you please give me a quick call and we clarify. Btw... are you planning to provide a fix for this?

@jafarre-bi jafarre-bi changed the title The API endpoint /project/validate?projectName=xxxx misinterprets projectName as projectKey The API endpoint /project/validate?projectName=xxxx searches by project key instead of project name Oct 25, 2021
@jafarre-bi
Copy link
Author

I have edited the ticket to try to make it clearer. @stitakis we can talk about it any time, thank you.

@stitakis
Copy link
Member

As verified, the two related API have the same implementation:
/validate

public ResponseEntity<Object> validateProject(@RequestParam(value = "projectName") String name) {

and /key/validate

@RequestMapping(method = RequestMethod.GET, value = "/template/{key}")

Options:

  1. we remove the API /validate as it might not be needed
  2. if it is needed, we should verify if the calling code actually could call /key/validate instead
  3. if not, we could implement this API to check if the project name exists in jira or even in the local storage to avoid to query Jira as this will have a better performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants