Skip to content

Commit

Permalink
Add "OpenEO-Identifier" response header on sync requests
Browse files Browse the repository at this point in the history
  • Loading branch information
soxofaan committed May 2, 2024
1 parent 4903fbd commit addcdb3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openeo_driver/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,10 @@ def result(user: User):
backend_implementation.request_costs(success=False, user=user, request_id=request_id)
raise

# Add request id as "OpenEO-Identifier" like we do for batch jobs.
# TODO: follow-up standardization at https://github.com/Open-EO/openeo-api/pull/533
response.headers["OpenEO-Identifier"] = request_id

return response

@blueprint.route('/execute', methods=['POST'])
Expand Down
8 changes: 8 additions & 0 deletions tests/test_views_execute.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import dataclasses
import dirty_equals
import json
import math
import re
Expand Down Expand Up @@ -4223,3 +4224,10 @@ def test_to_scl_dilation_mask_defaults(api, arguments, expected):
args, kwargs = dummy.to_scl_dilation_mask.call_args
assert args == ()
assert kwargs == expected


def test_synchronous_processing_response_header_openeo_identifier(api):
with mock.patch.object(FlaskRequestCorrelationIdLogging, "_build_request_id", return_value="r-abc123"):
res = api.result({"add1": {"process_id": "add", "arguments": {"x": 3, "y": 5}, "result": True}})
assert res.assert_status_code(200).json == 8
assert res.headers["OpenEO-Identifier"] == "r-abc123"

0 comments on commit addcdb3

Please sign in to comment.