Skip to content

PR #80: DB error from document_edits status update silently ignored after PII log removal #86

@bmersereau

Description

@bmersereau

Found in PR #80 (fix/71-remove-pii-logging)

Severity: Major

While removing PII-containing console.log calls, the error variables from two DB updates were also dropped, making DB failures completely silent:

Path 1 — status-only update (change_id not found in docx):

// Before: const { error: updErr } = await db...  console.log('status-only update', { updErr })
// After:
await db
    .from("document_edits")
    .update({ status: ..., resolved_at: ... })
    .eq("id", editId);
// Error completely ignored — if this fails, we return ok:true with stale DB state

Path 2 — main status update (after file overwrite):

// Before: const { error: statusErr } = await db...  console.log('updated status', { statusErr })
// After:
await db
    .from("document_edits")
    .update({ status: ..., resolved_at: ... })
    .eq("id", editId);
// Error completely ignored

If either DB update fails (network blip, RLS policy, constraint), the handler returns { ok: true } while the edit remains in pending state in the database. The UI will show the edit as resolved when it isn't.

Fix: Restore the error destructuring without the console.log:

const { error: updErr } = await db.from("document_edits").update(...).eq("id", editId);
if (updErr) {
    console.error("[edit-resolution] failed to update edit status", { error: updErr.message });
    return void res.status(500).json({ detail: "Failed to save resolution" });
}

The console.error is acceptable — the issue only prohibits PII at INFO level. An opaque error message without IDs is safe.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions