common_issues - mamoorkhan/glasslewis GitHub Wiki
Frequently asked questions and solutions for common problems with the GlassLewis Platform.
Use Ctrl+F to search for your specific error message or issue type:
-
Authentication Issues:
AADSTS
,401
,403
,login
,token
-
CORS Issues:
CORS
,Access-Control
,preflight
-
Build Issues:
build
,compile
,restore
,package
-
Database Issues:
database
,connection
,migration
,EF
-
Deployment Issues:
deploy
,Azure
,GitHub Actions
-
Performance Issues:
slow
,timeout
,memory
,CPU
A: This means your redirect URI doesn't match what's registered in Azure.
Solution:
-
Check your Angular environment configuration:
// environment.ts msalConfig: { auth: { redirectUri: 'http://localhost:4200' // Must exactly match Azure } }
-
Verify Azure app registration:
- Azure Portal → App registrations → Your client app → Authentication
- Ensure redirect URI exactly matches (case-sensitive)
- Include both
http://localhost:4200
andhttp://localhost:4200/
Common mistakes:
- Missing trailing slash:
http://localhost:4200
vshttp://localhost:4200/
- HTTP vs HTTPS mismatch
- Wrong port number
A: This is usually a token audience or scope issue.
Solution:
-
Check your API configuration:
// appsettings.json { "AzureAd": { "ClientId": "your-api-client-id", // NOT the client app ID "Authority": "https://your-tenant.ciamlogin.com/" } }
-
Verify Angular is requesting correct scopes:
// environment.ts apiConfig: { scopes: ['api://your-api-client-id/Company.Read'], // Use API client ID uri: 'https://localhost:5001/api/v1/' }
-
Debug token claims:
- Use jwt.io to decode your access token
- Check
aud
(audience) claim matches your API client ID - Check
scp
(scope) claim includes required permissions
A: Admin consent hasn't been granted for API permissions.
Solution:
- Go to Azure Portal → App registrations → Your client app → API permissions
- Click "Grant admin consent for [Your Organization]"
- Verify all permissions show green checkmarks
- If still failing, try these steps:
# Clear browser cache and cookies # Open incognito/private window # Try authentication again
A: Production URLs not configured in Azure app registrations.
Solution:
-
Update client app registration redirect URIs:
Add: https://your-production-domain.com Add: https://your-production-domain.com/auth/callback
-
Update CORS configuration in API:
// Program.cs app.UseCors(policy => policy.WithOrigins("https://your-production-domain.com") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials());
-
Update Angular production environment:
// environment.prod.ts export const environment = { msalConfig: { auth: { redirectUri: 'https://your-production-domain.com' } } };
A: CORS policy not configured correctly for your frontend domain.
Solution:
-
Check API CORS configuration:
// Program.cs builder.Services.AddCors(options => { options.AddPolicy("AllowedOrigins", policy => { policy.WithOrigins( "http://localhost:4200", // Local development "https://your-app.azurestaticapps.net" // Production ) .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); }); }); app.UseCors("AllowedOrigins");
-
Verify CORS middleware order:
// Correct order in Program.cs app.UseRouting(); app.UseCors("AllowedOrigins"); // Before authentication app.UseAuthentication(); app.UseAuthorization(); app.MapControllers();
-
Check for multiple CORS configurations:
# Search for multiple CORS configurations grep -r "UseCors\|AddCors" src/
A: API not handling OPTIONS requests correctly.
Solution:
-
Ensure CORS policy allows all methods:
policy.AllowAnyMethod() // Includes OPTIONS
-
Check if authentication is blocking preflight:
// Don't require auth on OPTIONS requests app.UseWhen(context => context.Request.Method != "OPTIONS", app => app.UseAuthentication());
-
Test preflight manually:
curl -X OPTIONS \ -H "Origin: http://localhost:4200" \ -H "Access-Control-Request-Method: GET" \ -H "Access-Control-Request-Headers: Authorization" \ https://localhost:5001/api/v1/companies
A: .NET SDK not installed or not in PATH.
Solution:
-
Windows:
winget install Microsoft.DotNet.SDK.8 # Or download from https://dotnet.microsoft.com/download
-
macOS:
brew install --cask dotnet-sdk
-
Linux:
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb sudo dpkg -i packages-microsoft-prod.deb sudo apt-get update sudo apt-get install -y dotnet-sdk-8.0
-
Verify installation:
dotnet --version # Should show 8.0.x
A: Angular CLI not installed globally.
Solution:
# Uninstall any existing versions
npm uninstall -g @angular/cli
# Clear npm cache
npm cache clean --force
# Install latest Angular CLI
npm install -g @angular/cli@17
# Verify installation
ng version
A: Package sources not configured or network issues.
Solution:
-
Check package sources:
dotnet nuget list source
-
Clear NuGet cache:
dotnet nuget locals all --clear
-
Restore with verbose logging:
dotnet restore --verbosity detailed
-
Check for corporate proxy:
# If behind corporate firewall dotnet nuget add source https://api.nuget.org/v3/index.json --name nuget.org
A: Node.js running out of memory during build.
Solution:
-
Increase Node.js memory:
export NODE_OPTIONS="--max-old-space-size=8192" ng build --configuration production
-
Use incremental builds:
ng build --configuration production --optimization=false
-
Check for circular dependencies:
npm install -g madge madge --circular src/
A: Database server not running or connection string incorrect.
Solution:
-
Check LocalDB status (Windows):
SqlLocalDB info SqlLocalDB start MSSQLLocalDB
-
Test connection string:
# From API project directory dotnet user-secrets list # Verify ConnectionStrings:DefaultConnection is set
-
Use Docker SQL Server:
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=YourStrong!Passw0rd" \ -p 1433:1433 --name glasslewis-sql \ -d mcr.microsoft.com/mssql/server:2022-latest # Update connection string to: # Server=localhost,1433;Database=GlassLewisDb;User Id=sa;Password=YourStrong!Passw0rd;Encrypt=false;
-
Use SQLite for simplicity:
dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Data Source=GlassLewisDb.sqlite"
A: Migration conflicts or database schema issues.
Solution:
-
Check migration status:
cd src/GlassLewis.Api dotnet ef migrations list
-
Reset migrations (development only):
# Remove all migrations rm -rf Migrations/ # Create fresh migration dotnet ef migrations add InitialCreate dotnet ef database update
-
Handle migration conflicts:
# Remove last migration dotnet ef migrations remove # Create new migration dotnet ef migrations add FixConflict
-
Update database manually:
dotnet ef database update --verbose
A: Migrations haven't been applied.
Solution:
cd src/GlassLewis.Api
# Apply pending migrations
dotnet ef database update
# Verify tables created
dotnet ef dbcontext info
A: Usually authentication or permission issues.
Solution:
-
Check GitHub secrets:
# Verify these secrets exist in GitHub repository settings: AZURE_CREDENTIALS # JSON with service principal details API_CLIENT_ID # API app registration ID CLIENT_APP_ID # Client app registration ID TENANT_ID # Azure tenant ID
-
Verify service principal permissions:
# Test service principal login az login --service-principal \ --username $SERVICE_PRINCIPAL_ID \ --password $SERVICE_PRINCIPAL_SECRET \ --tenant $TENANT_ID # Check permissions az role assignment list --assignee $SERVICE_PRINCIPAL_ID
-
Check Azure resource group exists:
az group show --name rg-glasslewis-prod
-
Review GitHub Actions logs:
- Go to GitHub → Actions → Failed workflow
- Expand failed steps
- Look for specific error messages
A: Configuration or startup issues.
Solution:
-
Check Application Insights logs:
az monitor app-insights events show \ --app ai-glasslewis-prod \ --resource-group rg-glasslewis-prod
-
Check App Service logs:
az webapp log tail \ --name app-glasslewis-api-prod \ --resource-group rg-glasslewis-prod
-
Verify app settings:
az webapp config appsettings list \ --name app-glasslewis-api-prod \ --resource-group rg-glasslewis-prod
-
Test locally with production configuration:
export ASPNETCORE_ENVIRONMENT=Production dotnet run
A: Build configuration or routing issues.
Solution:
-
Check build configuration:
# .github/workflows/azure-static-web-apps.yml app_location: "clients/glasslewis.client.angular" output_location: "dist/glasslewis-client"
-
Verify Angular build succeeds:
cd clients/glasslewis.client.angular npm ci ng build --configuration production
-
Check Static Web App routing:
# staticwebapp.config.json { "routes": [ { "route": "/api/*", "allowedRoles": ["authenticated"] }, { "route": "/*", "serve": "/index.html", "statusCode": 200 } ] }
A: Database performance or inefficient queries.
Solution:
-
Enable query logging:
// appsettings.Development.json { "Logging": { "LogLevel": { "Microsoft.EntityFrameworkCore.Database.Command": "Information" } } }
-
Check database indexes:
// Verify indexes are created modelBuilder.Entity<Company>() .HasIndex(c => c.Isin) .IsUnique();
-
Use async methods:
// Use async database operations await _context.Companies.ToListAsync();
-
Profile with Application Insights:
# Check dependency calls in Azure Portal az monitor app-insights events show --app ai-glasslewis-prod --event-types dependencies
A: Bundle size or loading issues.
Solution:
-
Analyze bundle size:
ng build --configuration production --stats-json npx webpack-bundle-analyzer dist/glasslewis-client/stats.json
-
Enable lazy loading:
// app-routing.module.ts const routes: Routes = [ { path: 'companies', loadChildren: () => import('./companies/companies.module').then(m => m.CompaniesModule) } ];
-
Optimize images and assets:
# Compress images npm install -g imagemin-cli imagemin src/assets/images/* --out-dir=dist/assets/images
-
Use OnPush change detection:
@Component({ changeDetection: ChangeDetectionStrategy.OnPush })
A: Another process using the same port.
Solution:
-
Find process using port:
# Windows netstat -ano | findstr :5001 # macOS/Linux lsof -i :5001
-
Kill process:
# Windows taskkill /PID <process-id> /F # macOS/Linux kill -9 <process-id>
-
Use different ports:
# For .NET API dotnet run --urls="https://localhost:5002;http://localhost:5003" # For Angular ng serve --port 4201
A: File watching or compilation issues.
Solution:
-
For .NET hot reload:
dotnet watch run --verbosity detailed
-
For Angular hot reload:
ng serve --poll=2000 # Poll every 2 seconds
-
Check file system watchers:
# Linux: Increase inotify watchers echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf sudo sysctl -p
A: Development certificates not trusted.
Solution:
# Clean and recreate certificates
dotnet dev-certs https --clean
dotnet dev-certs https --trust
# Verify certificate
dotnet dev-certs https --check --trust
For Chrome users:
- Go to
chrome://flags/#allow-insecure-localhost
- Enable "Allow invalid certificates for resources loaded from localhost"
A: Environment differences or missing dependencies.
Solution:
-
Check test environment:
# .github/workflows/ci.yml - name: Run tests run: dotnet test --configuration Release --logger trx --results-directory "TestResults" env: ASPNETCORE_ENVIRONMENT: Testing
-
Use InMemory database for tests:
// Test setup services.AddDbContext<CompanyDbContext>(options => options.UseInMemoryDatabase($"TestDb_{Guid.NewGuid()}"));
-
Mock external dependencies:
var mockHttpClient = new Mock<HttpClient>(); services.AddSingleton(mockHttpClient.Object);
A: Timing issues or flaky selectors.
Solution:
-
Add explicit waits:
// Playwright await Page.WaitForSelectorAsync("[data-testid='company-list']"); await Page.WaitForLoadStateAsync(LoadState.NetworkIdle);
-
Use stable selectors:
<!-- Use data-testid instead of classes --> <button data-testid="save-company">Save</button>
-
Run tests in headed mode:
dotnet test -- Playwright.LaunchOptions.Headless=false
- Authentication Troubleshooting - Detailed auth issues
- Azure Setup Guide - Complete setup instructions