[PDB-1473] firm up behavior around empty lists vs 404s for nonexistent data Created: 2015/05/04  Updated: 2015/07/10  Resolved: 2015/06/04

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

Type: Improvement Priority: Normal
Reporter: Wyatt Alt Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Relates
Template:
Story Points: 2
Sprint: PuppetDB 2015-06-03, PuppetDB 2015-06-17

 Description   

The console UI team needs to be able to differentiate between "nonexistent node" and "no data for existing node" when they issue the query

curl -X GET http://localhost:8080/v4/nodes/fakenode/facts

Talking with, Russell Mull I think we reached the following proposal:

Our shorthand endpoints follow the pattern
/<endpoint>/<identifier>/<subselect>/...

If the result of filtering <endpoint> to all values matching <identifier> is an empty list, then /<endpoint>/<identifier> and any children thereof should 404.

If the result of filtering <endpoint> to all values matching <identifier> is nonempty, then all children should be lists, empty or not.



 Comments   
Comment by Ken Barber [ 2015/05/21 ]

Did a quick survey of the impact so we know where the incorrect parts are: https://docs.google.com/spreadsheets/d/1ya_IPOgPYw_e9POAGmPJDd5YbqiNO32hLZDoCq5JL5w/edit#gid=0

In short it looks like:

/v4/nodes/<node>/facts
/v4/nodes/<node>/facts/<name>
/v4/nodes/<node>/facts/<name>/<value>
/v4/nodes/<node>/resources
/v4/nodes/<node>/resources/<type>
/v4/nodes/<node>/resources/<type>/<title>
/v4/environments/<environment>/events|facts|reports|resources
/v4/factsets/<node>/facts
/v4/catalogs/<node>/edges
/v4/catalogs/<node>/resources
/v4/reports/<hash>/events
/v4/reports/<hash>/metrics
/v4/reports/<hash>/logs

... all return 200's with empty arrays when there is no parent data.

Comment by Ken Barber [ 2015/05/27 ]

Patch is here: https://github.com/puppetlabs/puppetdb/pull/1419

Doc I used to analyse the endpoints that were broken: https://docs.google.com/spreadsheets/d/1ya_IPOgPYw_e9POAGmPJDd5YbqiNO32hLZDoCq5JL5w/edit#gid=0

Generated at Sun Jun 16 16:41:16 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.