Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/Data/Repositories/ForwardingHtlcEventRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,11 @@ public ForwardingHtlcEventRepository(IDbContextFactory<ApplicationDbContext> dbC
}
catch (DbUpdateException e) when (e.InnerException is PostgresException pg && pg.SqlState == PostgresErrorCodes.UniqueViolation)
{
_logger.LogDebug("Skipping duplicated forwarding HTLC event for node {ManagedNodePubKey}", forwardingHtlcEvent.ManagedNodePubKey);
_logger.LogDebug(
"Skipping duplicate forwarding HTLC event for node {ManagedNodePubKey} (in {IncomingChannelId}:{IncomingHtlcId} -> out {OutgoingChannelId}:{OutgoingHtlcId})",
forwardingHtlcEvent.ManagedNodePubKey,
forwardingHtlcEvent.IncomingChannelId, forwardingHtlcEvent.IncomingHtlcId,
forwardingHtlcEvent.OutgoingChannelId, forwardingHtlcEvent.OutgoingHtlcId);
return (true, null);
}
catch (Exception e)
Expand Down
20 changes: 18 additions & 2 deletions src/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Identity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Diagnostics;
using Microsoft.Extensions.Logging;
using Quartz;
using OpenTelemetry.Trace;
using OpenTelemetry.Resources;
Expand Down Expand Up @@ -204,8 +206,22 @@ public static async Task Main(string[] args)
builder.Services.AddDbContextFactory<ApplicationDbContext>(
options =>
{
options.EnableSensitiveDataLogging();
options.EnableDetailedErrors();
// Sensitive-data logging dumps raw SQL parameter values (pubkeys, amounts,
// aliases) into logs, so keep it to dev only — never leak it in prod.
if (isDevEnvironment)
{
options.EnableSensitiveDataLogging();
options.EnableDetailedErrors();
}

// Duplicate-key violations on inserts like ForwardingHtlcEvents are expected
// and handled by the repositories (deduped/skipped). EF logs the failed command
// and SaveChanges at Error regardless of our catch, which floods prod with
// benign, verbose stack traces — downgrade both to Debug so they stay quiet.
options.ConfigureWarnings(warnings => warnings
.Log((RelationalEventId.CommandError, LogLevel.Debug))
.Log((CoreEventId.SaveChangesFailed, LogLevel.Debug)));

options.UseNpgsql(Constants.POSTGRES_CONNECTIONSTRING, options =>
{
options.UseQuerySplittingBehavior(QuerySplittingBehavior
Expand Down
Loading