PictoPy icon indicating copy to clipboard operation
PictoPy copied to clipboard

BUG: Failed manual XMP re-export of a clean image is never retried automatically

Open CodeWith-sakib opened this issue 4 days ago • 1 comments

Is there an existing issue for this?

  • [x] I have searched the existing issues

What happened?

What happened?

I found a retry-state bug in the XMP metadata export implementation.

When an image has already been successfully exported, its change_count and exported_count are equal. If a subsequent manual export fails, the failure is recorded in the database, but these counters remain unchanged.

The automatic export candidate query only selects images where:

  • exported_count IS NULL, or
  • change_count > exported_count

As a result, the failed image is no longer considered pending and is never automatically retried.

Steps to reproduce

  1. Select a PNG image and run an initial XMP export.
  2. Confirm that the export succeeds and change_count == exported_count.
  3. Temporarily make the image file unavailable.
  4. Run a manual export using xmp_export_run(include_clean=True).
  5. Confirm that the export fails with FileNotFoundError.
  6. Restore the image file.
  7. Run the automatic export.

Actual behavior

  • The manual export records last_outcome = 'failed'.
  • The export counters remain equal.
  • The automatic candidate query returns no candidate for the image.
  • The automatic export does not retry the failed image.
  • Export counts can misleadingly report pending = 0 and failed = 0.

Expected behavior

A failed export of a previously exported image should remain eligible for automatic retry, even when its change and exported counters are equal.

The failure status should also be reflected accurately in export status reporting.

Suspected root cause

In backend/app/database/xmp_export_state.py, the pending candidate condition is:

(s.exported_count IS NULL OR s.change_count > s.exported_count)

In addition, db_record_xmp_export_failure() records the failure but does not update the export counters or otherwise make the image eligible for retry.

Existing test coverage

I checked the existing XMP export tests. They cover failures on initially pending images and missing files before a successful export, but I could not find coverage for a failed manual re-export of an already-clean image.

Verification

I reproduced this locally using the actual exporter, SQLite state functions, and a real PNG in an isolated temporary database.

The exact reproduction confirmed that after restoring the image, the automatic candidate list was empty and no retry occurred.

Environment

  • Repository: AOSSIE-Org/PictoPy
  • OS: macOS
  • Component: Backend XMP metadata export

Record

  • [x] I agree to follow this project's Code of Conduct

CodeWith-sakib avatar Dec 01 '26 20:12 CodeWith-sakib

👋 Thanks for opening this issue! The maintainers will review it shortly. Till then, do not open any PR. This is a strict rule we like to follow around here :)

Discussions are carried on Discord.

Instead of commenting here, join the AOSSIE Discord server and go to Projects → PictoPy.

If you find this project useful, a GitHub star would be appreciated.

github-actions[bot] avatar Dec 01 '26 20:12 github-actions[bot]