We can close this ticket. Finally identified it's our code issue, somewhere try the exception and convert it to some other type's exception.
We can close ticket, since I disabled the dynamic claim feature per AI bot's suggestion
Hi,
We noticed that when the application (Micro Service template) is deployed to Azure Kubernetes, Applications insight show the application throw 401 exception, the error details as below:
Failed to refresh remote claims for user: ae264b2c-aa17-336e-500c-3a0f39672a03 Volo.Abp.AspNetCore.Authentication.JwtBearer.DynamicClaims.WebRemoteDynamicClaimsPrincipalContributorCache
Do you have any clue about the error?
Thanks,
Can close this ticket. I gave two short of lock grace period, and I also add a loop / sleep try n times to acquire the lock. Then the code works
We have a distributed lock code like this, but it seems, the second thread didn't wait till first thread finished db insert
await using var handle = await _distributedLock.TryAcquireAsync($"api-lock", TimeSpan.FromMinutes(5));
try {
if (handle != null)
{
var rtCertifcate = _apiClient.CallApi (); //external API
if (!string.IsNullOrWhiteSpace(rtCertifcate ))
{
//insert into database for rtCertifcate
return rtCertifcate
}
}
else
{
// If we can't acquire the lock, fall back to database lookup
Logger.LogWarning("....");
}
}
catch
{
}
//Code read certificate from database
The backend is as above in Api project. The client angular network tab, response is plain error message.
If the API call handle the error message, the Angular UI does catch the UserFriendlyException message, say the angular show the message in a toaster or display direct on a UI element. However, at the same time, the Generic Internal Error exception window also shows up. I don't want the second one, or the second one should be message in UserFriendlyException
Actually I tried UserFriendlyException, BusinessException, Exception, from backend Swagger, the error code is 400, the response content is plain text error message, instead of JSON format. I have this code below in HttpApi.Host module file:
if (env.IsDevelopment())
{
//app.UseDeveloperExceptionPage();
}
app.UseCorrelationId();
app.UseAbpRequestLocalization();
app.UseStaticFiles();
app.UseAbpExceptionHandling();
app.UseRouting();
Another interesting thing is, I use this code below in a controller method:
return StatusCode(400, new
{
error = new
{
message = "Your user-friendly message in json",
details = (string?)null,
code = (string?)null
}
});
The angular side doesn't display the message neither