geopython / pygeoapi

pygeoapi is a Python server implementation of the OGC API suite of standards. The project emerged as part of the next generation OGC API efforts in 2018 and provides the capability for organizations to deploy a RESTful OGC API endpoint using OpenAPI, GeoJSON, and HTML. pygeoapi is open source and released under an MIT license.
https://pygeoapi.io
MIT License
459 stars 250 forks source link

Error returned if the output is an array #1674

Closed francescoingv closed 3 weeks ago

francescoingv commented 1 month ago

Description When the output is defined to be an array the execution returns: Error executing process: cannot access local variable 'mode' where it is not associated with a value

Steps to Reproduce If the process metadata defined the following outputs:

  'outputs': {
    'title': 'Output result',
    'test_out': {
      'description': 'my test',
      'minOccurs': 2,
      'maxOccurs': 2,
      'schema': {
        'type': 'array',
        'minItems': 3,
        'maxItems': 3,
        'items': {
          'type': 'string'
        }
      }
    }

I understand the process execute() should return something like the following:

[ "application/json" ,
  [ { "value" :  [ "String 1 A" , "String 2 A" , "String 3 A" ] },
    { "value" :  [ "String 1 B" , "String 2 B" , "String 3 B" ] }
  ]
]

where the returned outputs is an array. However, if the above is returned by process execute(), then the error is returned.

I identified the problem in BaseManager._execute_handler_sync() as the variable 'mode' is only set if outputs is either a dict or bytes.

Expected behavior Not sure if the execution should return:

[ { "value" :  [ "String 1 A" , "String 2 A" , "String 3 A" ] },
  { "value" :  [ "String 1 B" , "String 2 B" , "String 3 B" ] }
]

or

{
  [ { "value" :  [ "String 1 A" , "String 2 A" , "String 3 A" ] },
    { "value" :  [ "String 1 B" , "String 2 B" , "String 3 B" ] }
  ]
}

Environment

tomkralidis commented 3 weeks ago

@francescoingv PR in #1675