diff --git a/openeo_driver/ProcessGraphDeserializer.py b/openeo_driver/ProcessGraphDeserializer.py index d55a9328..eaed4858 100644 --- a/openeo_driver/ProcessGraphDeserializer.py +++ b/openeo_driver/ProcessGraphDeserializer.py @@ -1872,7 +1872,7 @@ def evaluate_process_from_url(process_id: str, namespace: str, args: dict, env: raise OpenEOApiException( status_code=400, code="ProcessNamespaceInvalid", - message=f"The value passed for namespace '{namespace}' in process '{process_id}' is invalid: {e}", + message=f"Process '{process_id}' specified with invalid namespace '{namespace}': {e!r}", ) from e return _evaluate_process_graph_process( diff --git a/openeo_driver/processgraph.py b/openeo_driver/processgraph.py index b37392dc..7e8c31c4 100644 --- a/openeo_driver/processgraph.py +++ b/openeo_driver/processgraph.py @@ -64,7 +64,9 @@ def get_process_definition_from_url(process_id: str, url: str) -> ProcessDefinit spec = found[0] else: raise OpenEOApiException( - status_code=400, code="ProcessNotFound", message=f"Process {process_id!r} not found in {url!r}." + status_code=400, + code="ProcessNotFound", + message=f"No valid process definition for {process_id!r} found at {url!r}.", ) return ProcessDefinition( diff --git a/tests/test_views_execute.py b/tests/test_views_execute.py index d189d929..3410537f 100644 --- a/tests/test_views_execute.py +++ b/tests/test_views_execute.py @@ -11,6 +11,7 @@ from typing import Iterable, Optional from unittest import mock, skip from zipfile import ZipFile +import http.client import geopandas as gpd import numpy as np @@ -2708,8 +2709,9 @@ def test_discard_result(api): "https://oeo.test/u/42/udp/bbox_mol", {"https://oeo.test/u/42/udp/bbox_mol": 404}, ( - 400, "ProcessUnsupported", - "'bbox_mol' is not available in namespace 'https://oeo.test/u/42/udp/bbox_mol'." + 400, + "ProcessNamespaceInvalid", + "Process 'bbox_mol' specified with invalid namespace 'https://oeo.test/u/42/udp/bbox_mol': HTTPError('404 Client Error: Not Found for url: https://oeo.test/u/42/udp/bbox_mol')", ), ), ( @@ -2717,8 +2719,8 @@ def test_discard_result(api): {"https://oeo.test/u/42/udp/bbox_mol": {"foo": "bar"}}, ( 400, - "ProcessResourceInvalid", - "Failed to load process 'bbox_mol' from 'https://oeo.test/u/42/udp/bbox_mol': KeyError('id')", + "ProcessNotFound", + "No valid process definition for 'bbox_mol' found at 'https://oeo.test/u/42/udp/bbox_mol'.", ), ), ( @@ -2726,8 +2728,8 @@ def test_discard_result(api): {"https://oeo.test/u/42/udp/bbox_mol": '{"foo": invalid json'}, ( 400, - "ProcessResourceInvalid", - "Failed to load process 'bbox_mol' from 'https://oeo.test/u/42/udp/bbox_mol': JSONDecodeError", + "ProcessNamespaceInvalid", + "Process 'bbox_mol' specified with invalid namespace 'https://oeo.test/u/42/udp/bbox_mol': JSONDecodeError('Expecting value: line 1 column 9 (char 8)')", ), ), ( @@ -2737,7 +2739,11 @@ def test_discard_result(api): "pg/1.0/udp/bbox_mol.json", preprocess=lambda t: t.replace("bbox_mol", "BBox_Mol") ) }, - None, + ( + 400, + "ProcessIdMismatch", + "Mismatch between expected process 'bbox_mol' and process 'BBox_Mol' defined at 'https://share.example/u42/bbox_mol.json'.", + ), ), ( "https://share.example/u42/bbox_mol.json", @@ -2765,7 +2771,7 @@ def test_evaluate_process_from_url(api, requests_mock, namespace, url_mocks, exp elif isinstance(value, dict): requests_mock.get(url, json=value) elif value in [404, 500]: - requests_mock.get(url, status_code=value) + requests_mock.get(url, status_code=value, reason=http.client.responses.get(value)) elif isinstance(value, tuple) and value[0] in [302]: status_code, target = value requests_mock.get(url, status_code=status_code, headers={"Location": target})