[PDB-950] PuppetDB returns 500 error as HTML when query contains invalid regex Created: 2014/10/10  Updated: 2015/07/10  Resolved: 2015/02/12

Status: Closed
Project: PuppetDB
Component/s: PE
Affects Version/s: PDB 2.2.0
Fix Version/s: PDB 3.0.0

Type: Bug Priority: Normal
Reporter: Steve Axthelm Assignee: Andrii Nikitiuk
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
Template:
Epic Link: Query Inconsistencies Phase 2
Story Points: 0
Sprint: PuppetDB 2014-11-19, PuppetDB 2014-12-03, PuppetDB 2014-12-17, PuppetDB 2014-12-31, PuppetDB 2015-01-14, PuppetDB 2015-01-28, PuppetDB 2015-02-11, PuppetDB 2015-02-25
QA Contact: Erik Dasher

 Description   

Entering an invalid regex pattern in a query causes PuppetDB to return a 500 error as `text/html`

Request:

curl -v 'http://localhost:8080/v3/nodes/kb.local/facts?query=\["~","name","*.foo"\]&include-total=true&limit=1'

Response:

HTTP/1.1 500 org.postgresql.util.PSQLException: ERROR: invalid regular expression: quantifier operand invalid
Cache-Control: must-revalidate,no-cache,no-store
Connection: close
Content-Length: 373
Content-Type: text/html; charset=ISO-8859-1
Date: Fri, 10 Oct 2014 17:43:35 GMT
Server: Jetty(9.1.z-SNAPSHOT)
 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-1"/>
<title>Error 500 </title>
</head>
<body>
<h2>HTTP ERROR: 500</h2>
<p>Problem accessing /v3/nodes. Reason:
<pre>    org.postgresql.util.PSQLException: ERROR: invalid regular expression: quantifier operand invalid</pre></p>
<hr /><i><small>Powered by Jetty://</small></i>
</body>
</html>

I would be nicer (for the NC UI for instance) if this were handled better and returned as JSON.



 Comments   
Comment by Ryan Senior [ 2014/10/22 ]

Returning JSON error messages would be a good thing, but something we would want to make the change to the whole application. So seems like the work here is to make this a 4xx error rather than a 5xx error for now, with a better error message

Comment by Lindsey Smith [ 2014/11/05 ]

Is this something that we could porentially cherrypick a fix for inclusion in PE 3.7.1?

Comment by Ken Barber [ 2014/11/05 ]

Lindsey Smith umm ... there is nothing to 'cherry pick' as the ticket hasn't been worked on, also we wouldn't do that anyway, we'd just target a fix at our stable branch if required which aligns with the 3.7.x PE branch. We'll take a look generally out how intrusive this change is for a stable branch release and make a decision when we get to this.

Comment by Ken Barber [ 2014/11/06 ]

Looks like we have a PR actually, not sure if thats why this triggered this comment Lindsey Smith? https://github.com/puppetlabs/puppetdb/pull/1142

Comment by Lindsey Smith [ 2014/11/06 ]

Thanks for the update Ken Barber. What trigger the comment was more learning that the PDB wasn't planning to do 2.x release in the near future, which would mean we wouldn't be able to get this into a PE 3.7.x unless went some route like cherrypicking a fix, etc.

Comment by Lindsey Smith [ 2014/11/06 ]

In any case, it's good that there's already a PR. Who would need to be involved with getting this into PE?

Comment by Ken Barber [ 2014/11/06 ]

Lindsey Smith we haven't expressed to anyone that we won't ship a 2.2.x, FYI. I'm not sure where you heard that . We are totally open to doing that. I would imagine this is a bug fix of a kind, so a 2.2.3 (and thus a 3.7.1) is not out of the question if its needed.

FYI we plan every second Wednesday, this is when we discuss priorities, this is your best bet for getting any votes into what we work on, as opposed to commenting on particular tickets - ie. this doesn't feed into our "operational" priority list generally. Alternatively you can proxy these through Steve Barlow who is our project manager. Point being, we get priorities from everywhere, and we have 3 product managers involved in our day to day which is crazy ... and yet no decent funnel beyond ourselves .

Comment by Steve Barlow [ 2014/11/06 ]

Ken Barber Lindsey Smith

Any confusion here is my fault. I was talking to Lindsey about Releases, and what I was trying to say that as of the moment there were no specific plans for a 2.2.x, and assuming nothing came in the change that like bugs or fix requests I did not think there would be one. I did not mean to imply that if business reasons came up that caused us to reevaluate that we would not do it.

Sorry for adding to confusion and I hope this makes sense now. If not, poke me again.

Generated at Mon Sep 23 08:12:08 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.