fix(documents): syncEntityFolderName defense-in-depth + log level
Two follow-ups from code review: 1. The UPDATE in the retry loop now scopes by both id and port_id so it matches every other mutation in document-folders.service.ts and honours the CLAUDE.md defense-in-depth pattern. 2. The three entity-rename hooks now log at warn level (not error) — a missed folder rename is best-effort cosmetic drift, not a paging incident. Matches the existing convention used elsewhere in the codebase for non-fatal background work. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -533,7 +533,7 @@ export async function updateClient(
|
||||
|
||||
if (data.fullName !== undefined) {
|
||||
await syncEntityFolderName(portId, 'client', id, meta.userId).catch((err) => {
|
||||
logger.error({ err, clientId: id }, 'Failed to sync client folder name');
|
||||
logger.warn({ err, clientId: id }, 'Failed to sync client folder name');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -185,7 +185,7 @@ export async function updateCompany(
|
||||
|
||||
if (data.name !== undefined) {
|
||||
await syncEntityFolderName(portId, 'company', id, meta.userId).catch((err) => {
|
||||
logger.error({ err, companyId: id }, 'Failed to sync company folder name');
|
||||
logger.warn({ err, companyId: id }, 'Failed to sync company folder name');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -561,7 +561,7 @@ export async function syncEntityFolderName(
|
||||
const [updated] = await db
|
||||
.update(documentFolders)
|
||||
.set({ name: candidate, updatedAt: new Date() })
|
||||
.where(eq(documentFolders.id, folder.id))
|
||||
.where(and(eq(documentFolders.id, folder.id), eq(documentFolders.portId, portId)))
|
||||
.returning();
|
||||
if (updated) return;
|
||||
} catch (err) {
|
||||
|
||||
@@ -165,7 +165,7 @@ export async function updateYacht(
|
||||
|
||||
if (data.name !== undefined) {
|
||||
await syncEntityFolderName(portId, 'yacht', id, meta.userId).catch((err) => {
|
||||
logger.error({ err, yachtId: id }, 'Failed to sync yacht folder name');
|
||||
logger.warn({ err, yachtId: id }, 'Failed to sync yacht folder name');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user