© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•7mo ago
benny

Malformed UUID Error Handling

Hello, I have a function that was written poorly as follows

export const IMAPtoUUID = (data: string): UUID => {
  console.log(`Converting IMAP ID to UUID: ${data}`);
  const padded = data.padEnd(32, '0');
  let result = `${padded.slice(0, 8)}-${padded.slice(8, 12)}-${padded.slice(12, 16)}-${padded.slice(16, 20)}-${padded.slice(20)}` as UUID;
  console.log(`Converted UUID: ${result}`);
  return result;
};

Converting IMAP ID to UUID: msg-f:1837281717662508024
Converted UUID: msg-f:18-3728-1717-6625-080240000000
export const IMAPtoUUID = (data: string): UUID => {
  console.log(`Converting IMAP ID to UUID: ${data}`);
  const padded = data.padEnd(32, '0');
  let result = `${padded.slice(0, 8)}-${padded.slice(8, 12)}-${padded.slice(12, 16)}-${padded.slice(16, 20)}-${padded.slice(20)}` as UUID;
  console.log(`Converted UUID: ${result}`);
  return result;
};

Converting IMAP ID to UUID: msg-f:1837281717662508024
Converted UUID: msg-f:18-3728-1717-6625-080240000000

But when that value is sent to my DB, no error is thrown, instead it shows
197f55fc-e597-e3f8-0000-000000000000
197f55fc-e597-e3f8-0000-000000000000


I have tried reverse engineering myself but I was unable to determine how this fix occurs. This is important because I would like to implement a UUIDtoIMAP function that reverses this, but cannot until I know the underlying algorthim.
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

UUID error?
SupabaseSSupabase / help-and-questions
4mo ago
Malformed Migration File
SupabaseSSupabase / help-and-questions
7mo ago
Error Handling Authentication
SupabaseSSupabase / help-and-questions
4y ago
RLS Error Handling
SupabaseSSupabase / help-and-questions
4y ago