hapi-server / server-issues

A place for tracking status of bugs in servers
0 stars 0 forks source link

Bad content for stream with header and no data #15

Open mbtaylor opened 9 months ago

mbtaylor commented 9 months ago

If I request data from the CDAweb service for a range with no data and supply the include=header parameter, I get a strange response:

% curl -s 'https://cdaweb.gsfc.nasa.gov/hapi/data?id=ISEE1_H0_FE&time.min=1978-08-03T04:43&time.max=1978-08-03T04:43:02&format=binary&parameters=Time,MODE&include=header'

#{
#"HAPI": "2.0",
#"status": {"code": 1200, "message": "OK"},
#"format": "binary",
#"parameters": [
#{
#"name": "Time",
#"type": "isotime",
#"units": "UTC",
#"length":24,
#"fill": null
#},
#{
#"name": "MODE",
#"type": "integer",
#"units": null,
#"fill": "-32768",
#"description": "Instrument Mode"
#}
#]
#}
,
"status": {"code": 1201, "message": "OK - no data for time range"}
}

The contents of the stream following the requested header is something that looks almost like a JSON status object, except that the initial open brace has been replaced with a comma.

With no include=header I get an actual JSON status object; that is less obviously a bug but it still appears to be behaviour which is as far as I can see undocumented at the declared v2.0 of the HAPI standard and illegal at v3.1(HAPI 3.1.0 Sec 3.7.6.3 "Time Range With No Data" says "For CSV or binary responses without a header, the message body should be empty to indicate no data records.")

I note also that behaviour changes if I request only the timestamp parameter; the following URLs give me no (corrupted or uncorrupted) JSON status object.

https://cdaweb.gsfc.nasa.gov/hapi/data?id=ISEE1_H0_FE&time.min=1978-08-03T04:43&time.max=1978-08-03T04:43:02&format=binary&parameters=Time
https://cdaweb.gsfc.nasa.gov/hapi/data?id=ISEE1_H0_FE&time.min=1978-08-03T04:43&time.max=1978-08-03T04:43:02&format=binary&parameters=Time&include=header