Skip to content

Commit

Permalink
fix(upload-files): handle JSONDecodeError (DEV-2907) (#621)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnussbaum committed Nov 6, 2023
1 parent 37040a6 commit 40000a8
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/dsp_tools/fast_xmlupload/upload_files.py
Expand Up @@ -8,6 +8,7 @@

import requests
from regex import regex
from requests import JSONDecodeError

from dsp_tools.connection.connection import Connection
from dsp_tools.models.exceptions import UserError
Expand Down Expand Up @@ -224,7 +225,12 @@ def _upload_without_processing(
),
)

if response_upload.json().get("message") == "server.fs.mkdir() failed: File exists":
try:
msg = response_upload.json().get("message")
except JSONDecodeError:
msg = None

if msg == "server.fs.mkdir() failed: File exists":
# This error can be safely ignored, since the file was uploaded correctly.
logger.info(f"In spite of 'server.fs.mkdir() failed: File exists', successfully uploaded file {file}")
elif response_upload.status_code != 200:
Expand Down

0 comments on commit 40000a8

Please sign in to comment.