disarm-platform / fn-covariate-extractor

OpenFaas version of the covariate extractor
MIT License
1 stars 0 forks source link

check for empty input #13

Closed onlyjsmith closed 4 years ago

onlyjsmith commented 5 years ago

Currently fails because it can't parse null input as JSON.

This probably affects ALL functions that use the same main.R implementation

Offending line from main.R is

params = fromJSON(readLines(file("stdin")))

Full response includes some extra text printed to STDOUT which we probably also want to handle in this case:

Attaching package: ‘geojsonio’

The following object is masked from ‘package:jsonlite’:

    validate

The following object is masked from ‘package:base’:

    pretty

Registered S3 method overwritten by 'crul':
  method                 from
  as.character.form_file httr
Registered S3 method overwritten by 'geojsonlint':
  method         from
  print.location geojsonio

Attaching package: ‘geojsonlint’

The following object is masked from ‘package:geojsonio’:

    as.location

Loading required package: sp
### Welcome to rworldmap ###
For a short introduction type :          vignette('rworldmap')
Linking to GEOS 3.5.1, GDAL 2.1.2, PROJ 4.9.3

Attaching package: ‘geosphere’

The following object is masked from ‘package:geojsonio’:

    centroid

{"type":"error","result":"Error: lexical error: invalid char in json text.\n                                       NA\n                     (right here) ------^\n\n"}
onlyjsmith commented 4 years ago

Not sure about this. Can't reproduce

  1. null is valid JSON, and is handled fine
fromJSON('null')
NULL
  1. empty string (i.e. nothing) is not valid JSON and shouldn't be handled

Perhaps there was an error coming from elsewhere, that's since been fixed. Will re-open if we find a reproducible case.