Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions supabase/functions/_backend/private/accept_invitation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,20 @@ async function ensurePublicUserRowExists(

let { error: insertError } = await supabaseAdmin.from('users').insert(insertPayload)

// Log any initial error for observability during rollout
if (insertError) {
cloudlog({
requestId: c.get('requestId'),
message: 'ensurePublicUserRowExists: initial insert error',
error: insertError,
})
}
Comment on lines +149 to +156
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These logs are recording insert failures; consider using cloudlogErr (stderr) instead of cloudlog so error-level logs can be filtered/alerted consistently across runtimes.

Copilot uses AI. Check for mistakes.

// Backward compatible rollout: if the column doesn't exist yet, retry without it.
if (isMissingCreatedViaInviteColumnError(insertError)) {
cloudlog({
requestId: c.get('requestId'),
message: 'ensurePublicUserRowExists: created_via_invite column missing, retrying without it',
error: insertError,
})
const { created_via_invite: _createdViaInvite, ...fallbackPayload } = insertPayload
;({ error: insertError } = await supabaseAdmin.from('users').insert(fallbackPayload))
Expand Down Expand Up @@ -444,12 +452,20 @@ app.post('/', async (c) => {
data,
} = await supabaseAdmin.from('users').insert(insertUserPayload).select().single()

// Log any initial error for observability during rollout
if (userNormalTableError) {
cloudlog({
requestId: c.get('requestId'),
message: 'accept_invitation: initial user insert error',
error: userNormalTableError,
})
}
Comment on lines +455 to +462
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is logging an actual insert error; consider emitting it via cloudlogErr (stderr) instead of cloudlog to keep error logs consistent and easier to detect in production logging pipelines.

Copilot uses AI. Check for mistakes.

// Backward compatible rollout: if the column doesn't exist yet, retry without it.
if (isMissingCreatedViaInviteColumnError(userNormalTableError)) {
cloudlog({
requestId: c.get('requestId'),
message: 'accept_invitation: created_via_invite column missing, retrying without it',
error: userNormalTableError,
})
const { created_via_invite: _createdViaInvite, ...fallbackPayload } = insertUserPayload
;({ error: userNormalTableError, data } = await supabaseAdmin.from('users').insert(fallbackPayload).select().single())
Expand Down
Loading