Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix WPS execute outputs parsing assuming string #623

Merged
merged 1 commit into from
Sep 9, 2021

Conversation

fmigneault
Copy link
Collaborator

Related Issue / Discussion

When parsing the XML of the WPS execute request (in parse_post_execute):

wpsrequest.outputs = get_output_from_xml(doc)

The outputs that do not provide a mimetype explicitly are defaulted to None:
outpt['mimetype'] = output_el.attrib.get('mimeType', None)

When those output definitions eventually reach the following call, the field mimetype exists and is None, making both the mimetype != '' compare and 'MimeType ' + mimetype + ' not valid' fail (raises cannot concatenate non-string).

pywps/pywps/app/Process.py

Lines 453 to 479 in cd71ee7

def setup_outputs_from_wps_request(self, wps_request):
# set as_reference to True for all the outputs specified as reference
# if the output is not required to be raw
if not wps_request.raw:
for wps_outpt in wps_request.outputs:
is_reference = wps_request.outputs[wps_outpt].get('asReference', 'false')
mimetype = wps_request.outputs[wps_outpt].get('mimetype', '')
if is_reference.lower() == 'true':
# check if store is supported
if self.store_supported == 'false':
raise StorageNotSupported(
'The storage of data is not supported for this process.')
is_reference = True
else:
is_reference = False
for outpt in self.outputs:
if outpt.identifier == wps_outpt:
outpt.as_reference = is_reference
if isinstance(outpt, ComplexOutput) and mimetype != '':
data_format = [f for f in outpt.supported_formats if f.mime_type == mimetype]
if len(data_format) == 0:
raise InvalidParameterValue(
'MimeType ' + mimetype + ' not valid')
outpt.data_format = data_format[0]

This PR simply sets it to the default ''

Additional Information

Contribution Agreement

(as per https://github.com/geopython/pywps/blob/master/CONTRIBUTING.rst#contributions-and-licensing)

  • I'd like to contribute [feature X|bugfix Y|docs|something else] to PyWPS. I confirm that my contributions to PyWPS will be compatible with the PyWPS license guidelines at the time of contribution.
  • I have already previously agreed to the PyWPS Contributions and Licensing Guidelines

@coveralls
Copy link

Coverage Status

Coverage remained the same at 0.0% when pulling 9e9dc23 on fmigneault:fix-mimetype-none into 1635529 on geopython:pywps-4.4.

@cehbrecht cehbrecht merged commit b5eb38b into geopython:pywps-4.4 Sep 9, 2021
@cehbrecht
Copy link
Collaborator

@fmigneault thanks :) Should we do a cherry-pick to bring this to the main branch?

@fmigneault
Copy link
Collaborator Author

@cehbrecht Yes. I believe this will still be an issue in main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants