fix: stop crash on start with empty sentry dsn, make max avatar length a constant
This commit is contained in:
parent
d87856bf2c
commit
142ff36d3a
2 changed files with 6 additions and 2 deletions
|
@ -18,7 +18,7 @@ builder.AddSerilog();
|
||||||
builder
|
builder
|
||||||
.WebHost.UseSentry(opts =>
|
.WebHost.UseSentry(opts =>
|
||||||
{
|
{
|
||||||
opts.Dsn = config.Logging.SentryUrl;
|
opts.Dsn = config.Logging.SentryUrl ?? "";
|
||||||
opts.TracesSampleRate = config.Logging.SentryTracesSampleRate;
|
opts.TracesSampleRate = config.Logging.SentryTracesSampleRate;
|
||||||
opts.MaxRequestBodySize = RequestSize.Small;
|
opts.MaxRequestBodySize = RequestSize.Small;
|
||||||
})
|
})
|
||||||
|
|
|
@ -162,6 +162,7 @@ public static partial class ValidationUtils
|
||||||
}
|
}
|
||||||
|
|
||||||
public const int MaxBioLength = 1024;
|
public const int MaxBioLength = 1024;
|
||||||
|
public const int MaxAvatarLength = 1_500_000;
|
||||||
|
|
||||||
public static ValidationError? ValidateBio(string? bio)
|
public static ValidationError? ValidateBio(string? bio)
|
||||||
{
|
{
|
||||||
|
@ -183,7 +184,10 @@ public static partial class ValidationUtils
|
||||||
return avatar?.Length switch
|
return avatar?.Length switch
|
||||||
{
|
{
|
||||||
0 => ValidationError.GenericValidationError("Avatar cannot be empty", null),
|
0 => ValidationError.GenericValidationError("Avatar cannot be empty", null),
|
||||||
> 1_500_000 => ValidationError.GenericValidationError("Avatar is too large", null),
|
> MaxAvatarLength => ValidationError.GenericValidationError(
|
||||||
|
"Avatar is too large",
|
||||||
|
null
|
||||||
|
),
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue