Excellent question. You are very close, and the error message from PostgreSQL is the key to solving this.
The error invalid input syntax for type uuid: "..." is telling you that the string you are trying to convert into a UUID is not in the correct format.
Let's look closely at the UUID you provided:
32e9b5cb-d033-4c57-a4b9-dcca911e013
A standard UUID has a specific structure of hexadecimal characters in an 8-4-4-4-12 format, for a total of 32 hexadecimal digits and 4 hyphens (36 characters total).
Let's break down your UUID by character count:
32e9b5cb - 8 characters. (Correct)
d033 - 4 characters. (Correct)
4c57 - 4 characters. (Correct)
a4b9 - 4 characters. (Correct)
dcca911e013 - 11 characters. (Incorrect)
The last section of a UUID must have 12 characters. Your string is missing one character at the end. You likely have a copy-paste error.
The Solution
You need to find the correct, full UUID for the user. Let's assume the last character was an f for this example. The correct UUID would be 32e9b5cb-d033-4c57-a4b9-dcca911e013f.
Once you have the correct 36-character UUID string, your third query attempt is the best and most idiomatic way to do this in PostgreSQL.
Correct Query:
sql
UPDATE public.session
SET expired_at = '2025-06-18 15:41:30.489 +00:00'
WHERE user_id = '32e9b5cb-d033-4c57-a4b9-dcca911e013f'::uuid; -- Replace with your actual, full UUID
Analysis of Your Attempts
It's helpful to know why your other queries were also problematic or less than ideal.
UPDATE ... WHERE user_id::text = "..."
Primary Issue: In SQL, double quotes (") are used for identifiers (like column or table names). Single quotes (') are for string literals. PostgreSQL would first try to find a column named "32e9b5cb-...", fail, and throw an error.
Performance Issue: Even if you used single quotes ('), casting the column (user_id::text) is inefficient. It forces PostgreSQL to convert every UUID in the table to text before doing the comparison, which prevents it from using an index on the user_id column and results in a slow full-table scan. Always cast the input value, not the column.
UPDATE ... WHERE user_id = cast('...' as uuid)
This syntax is perfectly correct and functional. It does the same thing as the ::uuid cast. It failed only because the string inside the single quotes was malformed.
UPDATE ... WHERE user_id = '...'::uuid
This is the most common and concise way to perform a type cast in PostgreSQL. It's functionally identical to the CAST() function. This is the recommended approach, and like the one above, it only failed because of the malformed UUID string.
In summary: Your logic was correct, but the data itself was flawed. Find the complete UUID, and your third query will work perfectly.