SIGN IN SIGN UP

fix: log swallowed DB errors in existence-check helpers

FeedExists, CategoryFeedExists, and CategoryIDExists in internal/storage
discarded the error from Scan() entirely. Since these run a
`SELECT true ... LIMIT 1` query, sql.ErrNoRows is the expected "doesn't
exist" case, but any OTHER error (a dropped connection, a query timeout,
pool exhaustion) took the same silent path -- callers in feed_handlers.go,
category_handlers.go, and entry_handlers.go treat a false return as
"404 Not Found", so a real infrastructure failure was indistinguishable
from a genuinely missing resource, and was never logged anywhere.

Kept the existing bool-only signature deliberately narrow in scope (a
signature change cascades into ~11 call sites across internal/api,
internal/ui, internal/validator, and internal/reader/handler, each with a
different error-handling convention -- too large a change for one focused
PR per this repo's own contribution guidelines). Instead, a genuine
(non-ErrNoRows) error is now logged via slog.Error before returning,
mirroring the existing pattern in CountWebAuthnCredentialsByUserID
(internal/storage/webauthn.go) -- so a real outage is at least observable
in server logs, even though the HTTP status code returned to the client
is unchanged by this PR.

Also fixed the same underlying pattern one layer up in
internal/ui/share.go's createSharedEntry: `if err != nil || entry == nil`
collapsed a genuine GetEntry() query error and an ordinary "no such
share link" into the same HTMLNotFound response. Split into two checks,
mirroring the HTMLServerError/HTMLNotFound split already used a few
lines earlier in the same function for EntryShareCode's error.

No new test added: there's no existing DB-error-injection test harness
for this package (no sqlmock, no integration-tagged test file for
feed.go/category.go), and building one just for this defensive/
observability-only change felt disproportionate to the fix's size.
Verified instead via `go build ./...`, `go vet ./...`, and the full
existing `go test ./...` suite (all pass, confirming no behavior
regression), plus gofmt -l reporting clean on all three touched files.
S
shiyongjiang committed
6ed1006a141105ca55746484efb8e65c08e4a7f8
Parent: 4998282
Committed by fguillot <323546+fguillot@users.noreply.github.com> on 8/2/2026, 2:58:04 PM