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

Add constraint for case-insensitive uniqueness of Content Type variables #18382

Closed
wezell opened this issue Apr 28, 2020 · 9 comments
Closed

Comments

@wezell
Copy link
Contributor

wezell commented Apr 28, 2020

We have a test that accidently added new Host content type, except lowercase host, which our schema allows. We should not allow this at the database level:

We have this constraint:

alter table structure add constraint unique_struct_vel_var_name unique (velocity_var_name);

It should be lower

alter table structure add constraint unique_struct_vel_var_name unique (lower(velocity_var_name));
@dsilvam dsilvam added this to the Bug Sprint milestone Apr 28, 2020
@dsilvam dsilvam self-assigned this Apr 28, 2020
@dsilvam
Copy link
Contributor

dsilvam commented Apr 29, 2020

PR: #18395

@dsilvam
Copy link
Contributor

dsilvam commented Apr 29, 2020

The validation was included at API level instead of a DB constraint.

@dsilvam dsilvam changed the title Add unique constraint on lower(structure(velocity_var_name)) Add constraint for case-insensitive uniqueness of Content Type variables Apr 30, 2020
@dsilvam dsilvam removed their assignment Apr 30, 2020
@nollymar nollymar self-assigned this May 5, 2020
@nollymar
Copy link
Contributor

nollymar commented May 5, 2020

Passed internal qa: Success. Tested through the content type api

@bryanboza
Copy link
Member

We need some work here:

  • Now we have the validation, but if you try to add a host content type at UI level we have the error in the log, but we are not showing a notification in the UI

  • If you try via API, we have the 400 response error wich is ok, but we need work in the response body, right now we are returning this:

<!doctype html>
<html lang="en">

<head>
	<title>HTTP Status 400 – Bad Request</title>
	<style type="text/css">
		h1 {
			font-family: Tahoma, Arial, sans-serif;
			color: white;
			background-color: #525D76;
			font-size: 22px;
		}

		h2 {
			font-family: Tahoma, Arial, sans-serif;
			color: white;
			background-color: #525D76;
			font-size: 16px;
		}

		h3 {
			font-family: Tahoma, Arial, sans-serif;
			color: white;
			background-color: #525D76;
			font-size: 14px;
		}

		body {
			font-family: Tahoma, Arial, sans-serif;
			color: black;
			background-color: white;
		}

		b {
			font-family: Tahoma, Arial, sans-serif;
			color: white;
			background-color: #525D76;
		}

		p {
			font-family: Tahoma, Arial, sans-serif;
			background: white;
			color: black;
			font-size: 12px;
		}

		a {
			color: black;
		}

		a.name {
			color: black;
		}

		.line {
			height: 1px;
			background-color: #525D76;
			border: none;
		}
	</style>
</head>

<body>
	<h1>HTTP Status 400 – Bad Request</h1>
	<hr class="line" />
	<p><b>Type</b> Status Report</p>
	<p><b>Message</b> Bad Request</p>
	<p><b>Description</b> The server cannot or will not process the request due to something that is perceived to be a
		client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
	</p>
	<hr class="line" />
	<h3>Apache Tomcat/8.5.32</h3>
</body>

</html>

@dsilvam
Copy link
Contributor

dsilvam commented May 7, 2020

Issue in comment above fixed by PR: #18449

@nollymar
Copy link
Contributor

nollymar commented May 8, 2020

Passed internal qa: The error reported by @bryanboza has been solved.

Testing in UI, this popup is displayed:
ContentTypeError

And the API response is a 400 error with this message:

{
  "message": "Content-type is not valid (Invalid content type variable: host)"
}

@bryanboza
Copy link
Member

bryanboza commented May 8, 2020

After the last changes now the endpoint is returning the response with the error, but when you try from UI, we are closing the new content type form and showing the error, after you close the pop-up we redirect to content types portlet. We need to redirect to the add new content type form again in order to update the name and create the content type.

Also since this is a handled error, we need show on logs just a line error, rigth now we are printing too many lines of error here: (as we do in the #17850 )
LOG: https://gist.github.com/bryanboza/1d85ae05f1001e66660957bdd1af973c

@bryanboza bryanboza removed the Needs QA label May 8, 2020
dsilvam added a commit that referenced this issue May 8, 2020
dsilvam added a commit that referenced this issue May 11, 2020
@dsilvam
Copy link
Contributor

dsilvam commented May 11, 2020

PR for one-line log when error #18457

@bryanboza
Copy link
Member

Fixed, the pending case was moved to a new card.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants