openvibers/openvibe.live Commits

Pastes: stop reporting render failures as "Paste not found"

OP OpenVibers committed 19 Aug 2026 · 5a73dc8b7e · 2 files, +12 −3

loadPasteViewer wrapped the fetch AND the whole render in one catch that always
rendered "Paste not found". So a rendering bug looked identical to a missing
paste — and that is exactly what happened here: /api/pastes/plum-dew-11 returns
200 with the full paste, yet the page claimed it did not exist, which sent this
hunt after the server while the API was healthy throughout.

Log the real error and separate the two cases: a genuine 404 still reads "Paste
not found", anything else now says the paste loaded but failed to render, and
shows the actual message.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Xw6Sf5zzSALw8m93XNu5JE

Changes

ddiff --git a/public/index.html b/public/index.html
iindex c63ebdf1..7dbe6f2f 100644
---- a/public/index.html
++++ b/public/index.html
@@@ -5041,7 +5041,7 @@ curl -s https://openvibe.media/live/@Goosely/chat-insight.json | jq ".chat_insig
<script src="/js/dashboard-moderation.js?v=5" defer></script>
<script src="/js/ai-viewers.js?v=1" defer></script>
<script src="/js/powerchat.js?v=6" defer></script>
--<script src="/js/pastes.js?v=11" defer></script>
++<script src="/js/pastes.js?v=12" defer></script>
<script src="/js/draggable-fab.js?v=2" defer></script>
<script src="/js/messenger.js?v=2" defer></script>
ddiff --git a/public/js/pastes.js b/public/js/pastes.js
iindex 8431f356..d21213d8 100644
---- a/public/js/pastes.js
++++ b/public/js/pastes.js
@@@ -385,11 +385,20 @@ async function loadPasteViewer(slug) {
// Load comments
loadPasteComments(p.slug, paste_id_for_js, p.user_id);
} catch (err) {
++ // This catch wraps BOTH the fetch and the entire render, so any rendering bug —
++ // a missing helper, a bad field — was reported as "Paste not found" even when the
++ // API had returned the paste perfectly. That mislabelling sent this bug hunt after
++ // the server for hours while the fetch was returning 200 the whole time.
++ // Distinguish the two, and surface the real error instead of inventing one.
++ console.error('[Pastes] Failed to display paste', slug, err);
++ const isMissing = /not found/i.test(err && err.message || '');
container.innerHTML = `
<div class="empty-state" style="text-align:center; padding:48px;">
<i class="fa-solid fa-circle-exclamation" style="font-size:2rem; color:var(--danger); margin-bottom:12px;"></i>
-- <h3>Paste not found</h3>
-- <p>It may have been deleted or the link is invalid.</p>
++ <h3>${isMissing ? 'Paste not found' : 'Couldn\u2019t display this paste'}</h3>
++ <p>${isMissing
++ ? 'It may have been deleted or the link is invalid.'
++ : `The paste loaded but failed to render: ${escapeHtml(String(err && err.message || err))}`}</p>
<button class="btn btn-primary" onclick="navigate('/pastes')" style="margin-top:16px;">Browse Pastes</button>
</div>`;
}