Skip to content

BUG: Folder loading error shows generic message, spams repeatedly, and retriggers on every window focus and restore #1555

Description

@g-k-s-03

Is there an existing issue for this?

I have searched the existing issues and found no duplicate.

What happened?

I was testing PictoPy on Windows and noticed something
really frustrating in Settings → Folder Management. Every
time I switched back to the app from another window, an
error dialog popped up. I kept closing it but it kept
coming back. I decided to dig into why this was happening
and ended up finding the root cause goes deeper than just
a UI issue.


The Problem

When the folder list fails to load, the app shows a
generic dialog that just says:

"An error occurred. Please try again."

But that's not even the real problem — it's just a symptom.
The actual error happening underneath is:

"Internal server error - Unable to retrieve folders:
no such column: f.indexing_status"

This happens because migration_009_add_indexing_status.py
exists in the codebase but the migration runner in
backend/app/database.py only applies migrations on
fresh installs. If you already had PictoPy installed and
upgraded, your database never gets the new column — so
every folder query fails silently.

On top of that, three things in the frontend make the
experience much worse than it needs to be:

1. The real error is hidden
The actual error message from the backend exists in the
code but gets thrown away before it reaches the user.
useFolderOperations.tsx never passes error: foldersQuery.error
into useMutationFeedback, so you always see the same
generic text no matter what actually went wrong.

Interestingly, the same file handles this correctly for
enable AI tagging, disable AI tagging, and delete folder —
it was just missed for the folder loading query.

2. The dialog spams every second
Because the query polls every 1000ms during AI tagging
and there's no deduplication in the feedback hook, the
error dialog reopens every second indefinitely. Closing
it does nothing — it comes straight back.

3. Switching apps triggers it instantly
Even without AI tagging running, switching away from
PictoPy and coming back immediately fires a new folder
fetch. If that fetch fails, the dialog appears right away.
This happens because foldersQuery is missing
refetchOnWindowFocus: false — a flag that taggingStatusQuery
right next to it in the same file already has set correctly.


Steps to Reproduce

  1. Install PictoPy on top of an existing older installation
  2. Open PictoPy → Settings → Folder Management
  3. Switch to any other app (Chrome, VS Code, anything)
  4. Switch back to PictoPy
  5. Error dialog appears immediately
  6. Close it — it comes back every second
  7. The dialog always shows a generic message with no
    useful information about what went wrong

Expected Behavior

  • The real backend error should be shown so users know
    what actually went wrong
  • The dialog should appear once, not spam every second
  • Switching back to PictoPy should not immediately
    trigger a fresh network request
  • Existing users upgrading from older versions should
    not hit database column errors

The Fix

The root cause is the migration runner — fixing that
stops the backend error entirely. The frontend fixes
ensure that even if any future backend error occurs,
it's shown properly and doesn't spam the user.

Backend fix (backend/app/database.py)
Update the migration runner to check and apply all
pending migrations on every startup, not just on fresh
installs. Existing data is untouched — the migration
only adds the missing column.

Frontend fixes (useFolderOperations.tsx and useMutationFeedback.tsx)

  • Pass the real error through so users see what actually went wrong
  • Pause polling when the query is in a persistent error state
  • Add refetchOnWindowFocus: false matching the sibling query
  • Add a dedupe guard so the same dialog never reopens while already visible

Impact

This affects every user who upgraded PictoPy from an
older version rather than doing a fresh install. The
spamming dialog and window-focus trigger affect all
users regardless of how they installed it.

Confirmed on the official v1.3.0-alpha Windows release.


Demo Video

bug.2.1.mp4

I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingpossible-duplicatePotential semantic duplicate (upstream comparison)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions