Skip to content

Commit 1b48941

Browse files
committed
Catch keyerror in async workers
1 parent f050b86 commit 1b48941

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

onadata/libs/utils/logger_tools.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,7 +677,12 @@ def safe_create_instance( # noqa C901
677677
response = OpenRosaResponse(_("Duplicate submission"))
678678
response.status_code = 202
679679
if request:
680-
response["Location"] = request.build_absolute_uri(request.path)
680+
try:
681+
response["Location"] = request.build_absolute_uri(request.path)
682+
except KeyError:
683+
# Handle cases where request doesn't have required META data
684+
# (e.g., synthetic requests from background tasks)
685+
pass
681686
error = response
682687
instance = None
683688
return [error, instance]

0 commit comments

Comments
 (0)