-
Notifications
You must be signed in to change notification settings - Fork 0
Implement 5 high-priority improvements: security, performance, error handling, logging, and resilience #543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,6 +10,7 @@ app.db | |
| app.db-shm | ||
| app.db-wal | ||
| .mono | ||
| logs/ | ||
|
|
||
| # Node.js dependencies | ||
| node_modules/ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -29,7 +29,20 @@ public async Task<IActionResult> OnGetAsync([FromRoute] string userName) | |
| { | ||
| if (userName != null) | ||
| { | ||
| GitHubUser = await Client.GetUserAsync(userName); | ||
| try | ||
| { | ||
| GitHubUser = await Client.GetUserAsync(userName); | ||
| } | ||
| catch (HttpRequestException) | ||
| { | ||
| ModelState.AddModelError(string.Empty, _localizer["ErrorFetchingProfile"]); | ||
| return Page(); | ||
| } | ||
| catch (Exception) | ||
| { | ||
| ModelState.AddModelError(string.Empty, _localizer["UnexpectedError"]); | ||
| return Page(); | ||
| } | ||
|
||
| } | ||
|
|
||
| return Page(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,9 +5,18 @@ | |||||
| using RazorPagesProject.Data; | ||||||
| using RazorPagesProject.Services; | ||||||
| using System.Globalization; | ||||||
| using Serilog; | ||||||
|
|
||||||
| var builder = WebApplication.CreateBuilder(args); | ||||||
|
|
||||||
| builder.Host.UseSerilog((context, services, configuration) => configuration | ||||||
| .ReadFrom.Configuration(context.Configuration) | ||||||
| .ReadFrom.Services(services) | ||||||
| .Enrich.FromLogContext() | ||||||
| .WriteTo.Console() | ||||||
| .WriteTo.File("logs/app-.txt", rollingInterval: RollingInterval.Day)); | ||||||
|
||||||
| .WriteTo.File("logs/app-.txt", rollingInterval: RollingInterval.Day)); | |
| .WriteTo.File("logs/app-{Date}.txt", rollingInterval: RollingInterval.Day)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in d4d1fb8. Changed the file path from "logs/app-.txt" to "logs/app-{Date}.txt" to include the date placeholder for proper daily rolling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HttpRequestExceptionの例外インスタンスをキャッチして、HTTP応答の詳細(ステータスコード、応答メッセージ)をロギングすべきです。これにより、GitHub APIの問題(レート制限、404エラーなど)のトラブルシューティングが容易になります。 / TheHttpRequestExceptioninstance should be caught and logged with HTTP response details (status code, response message). This will facilitate troubleshooting of GitHub API issues (rate limits, 404 errors, etc.).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in d4d1fb8. Added logging with HTTP response details including status code:
_logger.LogError(ex, "Failed to fetch GitHub profile for user '{UserName}'. Status: {StatusCode}", userName, ex.StatusCode)