🐞 One of the Weirdest Bugs

In n8n, some workflows suddenly stopped working. ⚠️

They were still listed, but when I tried to access them — 404 Not Found.
Yet, I could find them in the Postgres DB, so clearly the 404 was wrong. ⁉️

Digging Deeper 🕵️

  • Only the workflows with a Gmail trigger were broken.
  • Tried creating a new Gmail trigger — my credentials were missing. ⚠️
  • Checked the n8n credentials list — the Gmail credential was there, but clicking it → 404.

Something was fishy 🐟

Back to the Postgres DB:

  • The credential existed.
  • Searching for id = 'abc' → ❌ no result.
  • Searching for id LIKE '%abc%' → ✅ result found.

Thought: maybe a trailing whitespace?
Nope — the ID was clean.
I even compared the values in binary to make sure they are identical.

Then I asked @grok for ideas, and the 4th suggestion stood out:

🛠️ Rebuild indexes?

I have recently changed the postgres image to pgvector. But everything else worked. Could the indexes suddenly become corrupt?

The Fix ✅

Ran:

REINDEX TABLE credentials_entity;

Boom 💥

  • The ID could be found.
  • The credential worked.
  • Gmail triggers functioned.
  • Workflows came back to life. 🚀

🧠 Lessons Learned

  • After upgrading from a Postgres image to pgvector, REINDEX might be necessary.
  • If data exists but queries return 404, think corrupted indexes.
  • Broken core DB functionality = weird system behavior + misleading errors.
  • Always follow the rabbit hole when debugging. 🕳️🐇

Question for the experts:

Why was the index corrupted? Why was it only corrupted for a single value in the entire database? How can that even happen after changing the postgres image, if the volume is the same?

PS: I actually wrote down my thought process while it was happening: https://community.n8n.io/t/suddenly-cant-open-some-workflows-they-return-404/155650

Read more