pacificclimate / pdp_util

A package supplying numerous apps for running PCIC's data server
GNU General Public License v3.0
0 stars 0 forks source link

Properly handle requests for empty data/station lists #26

Open jameshiebert opened 3 years ago

jameshiebert commented 3 years ago

Issue #8 handled the potential for empty station lists being requested by the PCDS portal. However, I believe that the calling code can still fail.

        responders = chain(get_all_metadata_index_responders(self.session, stns, climo),
                           get_pcds_responders(self.dsn, stns, ext, get_clip_dates(environ), environ)
                           )

Assume that chain() gets two empty iterators. If it does this call to ziperator() will have no responders. If that's the case, there's some logic in this loop that assumes that the loop will be called at least once. If it's not called, the response will end up writing (I believe) "PKPK" (the second "PK" being the problem and a result of the incorrect logic) which is not a valid zip file.

A preferable behaviour would be to return a 404 response somewhere in __call__() with a helpful message about what parameters were received and about how there are no stations that meet the given criteria.