classify_errors.ps1 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Classify errors from api_errors_final.txt
  2. $lines = Get-Content 'd:\ylrz\saasadminui\api_errors_final.txt' -Encoding UTF8
  3. $err404 = [System.Collections.ArrayList]::new()
  4. $err500 = [System.Collections.ArrayList]::new()
  5. $errTimeout = [System.Collections.ArrayList]::new()
  6. $err403 = [System.Collections.ArrayList]::new()
  7. $errOther = [System.Collections.ArrayList]::new()
  8. foreach ($line in $lines) {
  9. if ($line -match '^404\|') { [void]$err404.Add($line) }
  10. elseif ($line -match '^500\|') { [void]$err500.Add($line) }
  11. elseif ($line -match '^0\|') { [void]$errTimeout.Add($line) }
  12. elseif ($line -match '^403\|') { [void]$err403.Add($line) }
  13. elseif ($line -match '^\d+\|') { [void]$errOther.Add($line) }
  14. }
  15. Write-Host "=== ERROR SUMMARY ==="
  16. Write-Host "404 NOT FOUND: $($err404.Count)"
  17. Write-Host "500 SERVER ERROR: $($err500.Count)"
  18. Write-Host "0 TIMEOUT/CONNECTION: $($errTimeout.Count)"
  19. Write-Host "403 FORBIDDEN: $($err403.Count)"
  20. Write-Host "OTHER: $($errOther.Count)"
  21. Write-Host ""
  22. # Extract unique URL prefixes from 404 errors
  23. Write-Host "=== 404 URL PREFIX GROUPS ==="
  24. $prefix404 = $err404 | ForEach-Object {
  25. if ($_ -match '404\|(/[^/]+/[^/]+)') { $matches[1] }
  26. elseif ($_ -match '404\|(/[^/]+)') { $matches[1] }
  27. } | Group-Object | Sort-Object Count -Descending
  28. $prefix404 | Format-Table Name, Count -AutoSize
  29. # Extract unique URL prefixes from TIMEOUT errors
  30. Write-Host "=== TIMEOUT URL PREFIX GROUPS ==="
  31. $prefixTimeout = $errTimeout | ForEach-Object {
  32. if ($_ -match '0\|([^/|]+)') { '/' + $matches[1] }
  33. } | Group-Object | Sort-Object Count -Descending
  34. $prefixTimeout | Format-Table Name, Count -AutoSize
  35. # Group 500 errors by type
  36. Write-Host "=== 500 ERROR TYPES ==="
  37. $err500Types = $err500 | ForEach-Object {
  38. if ($_ -match "Request method 'GET' not supported") { 'GET_NOT_SUPPORTED' }
  39. elseif ($_ -match 'Failed to convert.*NumberFormatException') { 'PATH_PARAM_CONFLICT' }
  40. elseif ($_ -match 'Unknown column') { 'SQL_COLUMN_MISSING' }
  41. elseif ($_ -match 'Required request parameter') { 'MISSING_PARAM' }
  42. elseif ($_ -match 'bad SQL grammar') { 'SQL_ERROR' }
  43. else { 'OTHER' }
  44. } | Group-Object | Sort-Object Count -Descending
  45. $err500Types | Format-Table Name, Count -AutoSize
  46. # Write 404 list
  47. Write-Host "=== ALL 404 ERRORS ==="
  48. $err404 | ForEach-Object { Write-Host $_ }
  49. # Write 500 list
  50. Write-Host "`n=== ALL 500 ERRORS ==="
  51. $err500 | ForEach-Object { Write-Host $_ }
  52. # Write timeout list
  53. Write-Host "`n=== ALL TIMEOUT ERRORS ==="
  54. $errTimeout | ForEach-Object { Write-Host $_ }