rocksdanister/lively · error · Exception
Auth code value cannot be null.
Error message
Auth code value cannot be null.
What it means
Thrown in the GalleryLoginViewModel GOOGLE branch when galleryClient.RequestCodeAsync("GOOGLE") returns null — the server did not hand back an OAuth code. Note it throws the base System.Exception, which limits structured handling. Identical logic to the GITHUB branch (error 10).
Source
Thrown at src/Lively/Lively.UI.Shared/ViewModels/Gallery/GalleryLoginViewModel.cs:71
private async Task Authenticate(string provider)
{
if (galleryClient.IsLoggedIn)
return;
IsProcessing = true;
Exception exception = null;
await Task.Run(async () =>
{
try
{
switch (provider)
{
case "GOOGLE":
{
var code = await galleryClient.RequestCodeAsync("GOOGLE");
if (code == null)
throw new Exception("Auth code value cannot be null.");
await galleryClient.AuthenticateGoogleAsync(code);
}
break;
case "GITHUB":
{
var code = await galleryClient.RequestCodeAsync("GITHUB");
if (code == null)
throw new Exception("Auth code value cannot be null.");
await galleryClient.AuthenticateGithubAsync(code);
}
break;
}
}
catch (Exception e)
{
exception = e;View on GitHub (pinned to c1036feb66)
Solutions
- Check network connectivity and that the gallery service is reachable.
- Retry RequestCodeAsync once; if still null, surface 'Google sign-in unavailable, try again or use another provider.'
- Server-side: verify the Google OAuth app credentials and redirect are configured.
- If maintaining the client, throw a typed AuthenticationException instead of base Exception.
Example fix
// before
var code = await galleryClient.RequestCodeAsync("GOOGLE");
if (code == null)
throw new Exception("Auth code value cannot be null.");
// after
var code = await galleryClient.RequestCodeAsync("GOOGLE");
if (string.IsNullOrEmpty(code))
throw new AuthenticationException("Gallery did not return a Google OAuth code; service may be unavailable."); Defensive patterns
Strategy: retry
Validate before calling
string code = null;
for (int i = 0; i < 2 && string.IsNullOrEmpty(code); i++)
code = await galleryClient.RequestCodeAsync("GOOGLE");
if (string.IsNullOrEmpty(code)) { ShowError("Google sign-in unavailable"); return; } Type guard
static bool IsValidAuthCode(string code) => !string.IsNullOrWhiteSpace(code);
Try / catch
try { await galleryClient.AuthenticateGoogleAsync(code); }
catch (Exception ex) when (ex.Message.Contains("Auth code value cannot be null"))
{ ShowError("Google OAuth unavailable, retry or use another provider."); } Prevention
- Retry RequestCodeAsync once for transient nulls.
- Offer a fallback provider when one returns null.
- Throw a typed AuthenticationException if you maintain the client.
When it happens
Trigger: RequestCodeAsync("GOOGLE") returns null due to a server-side error, network failure, or the gallery's Google OAuth not being configured. The view-model then cannot call AuthenticateGoogleAsync.
Common situations: Gallery server down or returning non-2xx; Google provider disabled server-side; client/network issue blocking the code request; regional blocking of the OAuth endpoint.
Related errors
AI-assisted analysis of rocksdanister/lively@c1036feb66 (2026-08-13).
Data as JSON: /api/errors/772e022861f62e33.
Report an issue: GitHub.