Skip to content

Commit b232229

Browse files
committed
improvement(files): log missing owner metadata distinctly on profile-picture delete deny
Per PR review: when a profile-picture delete is denied, distinguish a missing owner record (no userId metadata) from a genuine ownership mismatch so the fail-closed denial is diagnosable. Behavior unchanged — both still deny.
1 parent b9d004a commit b232229

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

apps/sim/app/api/files/authorization.ts

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -315,11 +315,24 @@ async function verifyPublicAssetWriteAccess(
315315
if (metadata.userId && metadata.userId === userId) {
316316
return true
317317
}
318-
logger.warn('profile-pictures delete denied: caller does not own the file', {
319-
userId,
320-
fileUserId: metadata.userId,
321-
cloudKey,
322-
})
318+
// Fail closed when the owner cannot be established. Distinguish a missing
319+
// owner record (no `userId` metadata — e.g. an object predating owner
320+
// tagging) from a genuine ownership mismatch so the denial is diagnosable.
321+
if (!metadata.userId) {
322+
logger.warn(
323+
'profile-pictures delete denied: file has no owner metadata to verify against',
324+
{
325+
userId,
326+
cloudKey,
327+
}
328+
)
329+
} else {
330+
logger.warn('profile-pictures delete denied: caller does not own the file', {
331+
userId,
332+
fileUserId: metadata.userId,
333+
cloudKey,
334+
})
335+
}
323336
return false
324337
}
325338

0 commit comments

Comments
 (0)