Auth session instantly invalid + PGRST116 errors (worked fine before)

I’ve been experiencing major issues with auth and database queries suddenly breaking. I’ve been working on this app for almost 2 years, adding features and expanding it. Recently, I noticed service updates on Supabase, and I strongly suspect something changed behind the scenes that’s now affecting my app. Suddenly, I'm getting PGRST116 errors ("JSON object requested, multiple (or no) rows returned") when querying my profiles table—even though the user exists and the ID is correct. At the same time, my auth session seems to expire or disappear immediately after logging in. I fetch the user via supabase.auth.getUser() and get a valid user.id, but follow-up calls to fetch profile data fail as if the user doesn’t exist. I haven’t made any changes related to auth in my code. I test thoroughly before every commit, and my last commit was a few days ago when everything was working perfectly. I’ve even checked out previous commits, and the app is now broken regarding auth.
useEffect(() => {
const fetchUserData = async () => {
const { data: { user } } = await supabase.auth.getUser();
setUser(user);

if (user) {
console.log('user id', user.id);
const { data, error } = await supabase
.from('profiles')
.select('is_reg_complete')
.eq('id', user.id)
.single();

if (error) {
console.log(error);
} else {
console.log('data', data);
setIsRegComplete(data?.is_reg_complete);
}
} else {
setIsRegComplete(null);
}

setLoading(false);
};

fetchUserData();
}, [supabase]);




Error:
json
{code: 'PGRST116', message: 'JSON object requested, multiple (or no) rows returned'}
useEffect(() => {
const fetchUserData = async () => {
const { data: { user } } = await supabase.auth.getUser();
setUser(user);

if (user) {
console.log('user id', user.id);
const { data, error } = await supabase
.from('profiles')
.select('is_reg_complete')
.eq('id', user.id)
.single();

if (error) {
console.log(error);
} else {
console.log('data', data);
setIsRegComplete(data?.is_reg_complete);
}
} else {
setIsRegComplete(null);
}

setLoading(false);
};

fetchUserData();
}, [supabase]);




Error:
json
{code: 'PGRST116', message: 'JSON object requested, multiple (or no) rows returned'}
6 Replies
garyaustin
garyaustin3w ago
Check the Dashboard log for the profile GET and see the role and id of the user (if authenticated versus anon) in the details.
Azro0891
Azro0891OP3w ago
Thank for your reply - ive just seen this:
No description
Azro0891
Azro0891OP3w ago
which is most definately my issue
garyaustin
garyaustin3w ago
Are you using the management API?
Azro0891
Azro0891OP3w ago
yes
garyaustin
garyaustin3w ago
OK. Just verifying as that one is resolved, you don't show that in the code above and it has nothing directly to do with Auth or the REST API.

Did you find this page helpful?