Skip to content

Report failed folder uploads and keep the description file - #222

Open
chrisdebian wants to merge 2 commits into
mapilio:mainfrom
chrisdebian:fix/report-folder-upload-failure
Open

chrisdebian wants to merge 2 commits into
mapilio:mainfrom
chrisdebian:fix/report-folder-upload-failure

Conversation

@chrisdebian

Copy link
Copy Markdown
Contributor

As you asked on #220. A failed folder upload was silent: upload() returned the failure in its result, nothing read it, the command exited 0, and the description file was removed in finally.

What changes:

  • Visible error: the failure is logged, with the path of the file that was kept.
  • Non-zero exit: the upload command now exits with an error when the upload fails.
  • Metadata kept: mapilio_image_description.json is removed only after a successful upload. It's also kept if the upload is interrupted with Ctrl+C.
  • Refused descriptions: if upload_desc() gets an HTTP error, that now counts as a failure. Before, it returned nothing and led to a confusing TypeError. If any sequence is refused, the whole upload is reported as failed, so the file is kept.

upload() still returns its result dictionary, because MapSyncer reads result['Success']. The new exception is raised in the upload command instead, so MapSyncer isn't affected.

Two things to check, please:

  • video_upload runs the upload command once per video, so it now stops at the first failed video, where before it carried on to the next. I think stopping is right, because each failure now needs attention, but it's a change in behaviour and your call.
  • The timeout and 429 replies aren't included, and the completion-response loop stays in Stop uploads on unexpected completion replies #221, as you said.

Testing: pytest gives 126 passed locally, including 5 new tests in tests/test_upload_failure.py. With the code change removed, 4 of the new tests fail. The tests don't import the full upload command path, because the test setup stubs some of its packages, so I also ran that path once by hand with a forced failure. It logged the error, exited with code 2 and kept the file. I haven't tried it against the real server.

This was written with Claude Code, and I've reviewed it.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Ue2Xf3pagU5DPwLibqEjFy

A failed folder upload was silent: upload() returned the failure in its
result, nothing read it, the command exited 0, and the description file
was removed in `finally`, so the upload couldn't simply be run again.

Now the failure is logged, the upload command exits non-zero, and the
description file is only removed after a successful upload. Refused
descriptions from upload_desc() also count as a failure. upload() still
returns its result dict, because MapSyncer reads it.
upload.py imports it at module level, and CI doesn't install it. tests.yml
already says it's stubbed in conftest.py, but it wasn't, because no test
imported upload.py until now.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant