Skip to content

Commit 23aad68

Browse files
committed
Catch keyerror in async workers
1 parent c66f21a commit 23aad68

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
@@ -680,7 +680,12 @@ def safe_create_instance( # noqa C901
680680
response = OpenRosaResponse(_("Duplicate submission"))
681681
response.status_code = 202
682682
if request:
683-
response["Location"] = request.build_absolute_uri(request.path)
683+
try:
684+
response["Location"] = request.build_absolute_uri(request.path)
685+
except KeyError:
686+
# Handle cases where request doesn't have required META data
687+
# (e.g., synthetic requests from background tasks)
688+
pass
684689
error = response
685690
instance = None
686691
return [error, instance]

0 commit comments

Comments
 (0)