Skip to content

Issue2501 Postgres returns inserted data in exception if insert fails#3008

Closed
dwat001 wants to merge 3 commits into
npgsql:hotfix/3.2.8from
dwat001:Issue2501_ExceptionDetailHasProductionData
Closed

Issue2501 Postgres returns inserted data in exception if insert fails#3008
dwat001 wants to merge 3 commits into
npgsql:hotfix/3.2.8from
dwat001:Issue2501_ExceptionDetailHasProductionData

Conversation

@dwat001

@dwat001 dwat001 commented Jun 11, 2020

Copy link
Copy Markdown
Contributor

As per comments in the Issue, this PR deals with both PostgresException.Details and the logging of command parameters.

If this approach gains approval I will apply the same change to the dev branch. Given the major version bump in the dev branch we could consider removing or deprecating NpgsqlLogManager.IsParameterLoggingEnabled I would not do that on the 3.X branch.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this is a suppression, not an inclusion, this description isn't quite accurate
Suggest swapping included with suppressed

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this commented?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞 Good catch thank you.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Description("When enabled prevents excludes the Postgres DETAIL response from raised exceptions. This DETAIL message often contains user data that may be sensative.")]
[Description("When enabled, removes the Postgres DETAIL property from raised exceptions. This DETAIL message can contain user data that should not be included in logs or displayed to users.")]

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread src/Npgsql/PostgresException.cs Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could place constant text in here to explain why it's missing?

"Detail suppressed as SuppressDetailInPostgressError is enabled"

dwat001 added 2 commits June 12, 2020 12:05
Based on a new ConnectionString property SuppressDetailInPostgressError drop the DETAILS field sent by postgres as this often contains user data which may be sensitive.
Based on a new connection string property, suppress the logging of Command parameters.
@dwat001 dwat001 force-pushed the Issue2501_ExceptionDetailHasProductionData branch from c076842 to 19c36ee Compare June 12, 2020 00:06
Comment thread src/Npgsql/PostgresException.cs Outdated
public PostgresException() {}

internal PostgresException(ReadBuffer buf)
internal PostgresException(ReadBuffer buf, NpgsqlConnectionStringBuilder settings)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to pass all settings, just add a bool flag instead.

[Description("When enabled prevents excludes the Postgres DETAIL response from raised exceptions. This DETAIL message often contains user data that may be sensative.")]
[DisplayName("Suppress Postgres Error Detail")]
[NpgsqlConnectionStringProperty]
public bool SuppressDetailInPostgressError

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably it would be better to call it SuppressDetailedExceptions or something like this. It should be short enough but meaningful.

@YohDeadfall

Copy link
Copy Markdown
Contributor

By the way, this PR should target the master branch.

…#2501)

Address review comments:
- Fix wording in Documentation
- Rename SuppressDetailInPostgressError to SuppressDetailedExceptions
- Pass bool flag not compleate settings object
- Replace Detail with message when removing
@dwat001

dwat001 commented Jun 12, 2020

Copy link
Copy Markdown
Contributor Author

By the way, this PR should target the master branch.

As per the description of this PR I am happy to land this in master, but I would also like this in the 3.X series.
Is it possible to get this PR into a good state and then I will do an equivalent against master?

@dwat001

dwat001 commented Jun 12, 2020

Copy link
Copy Markdown
Contributor Author

I have started a second PR to take the same change into master #3011

@YohDeadfall

Copy link
Copy Markdown
Contributor

Closing this in favour of #3011.

@williamdenton

Copy link
Copy Markdown
Contributor

Hey @YohDeadfall isn’t this pr required to get this change into the 3.x release line?

@YohDeadfall

Copy link
Copy Markdown
Contributor

We accept only bug fixes into hot fix branches which works only for the specific versions. For all general things like features and fixes for bugs existing in the current version pull requests must target the master branch. After merging we could backport them.

@YohDeadfall

Copy link
Copy Markdown
Contributor

@dwat001 @williamdenton Why do you stuck with so old version of Npgsql when there are 4.1 and 4.0? Any reason no to use them?

@williamdenton

Copy link
Copy Markdown
Contributor

@YohDeadfall you're totally right. I/We misspoke about v3.x. We are currently upgrading our services from dotnet 2.1 to 3.1, so updating EFCore too. I got confused with the microsoft pattern of tying version numbers to framework versions (which in itself is confusing given netstandard).

We currently use v4.0.8

We should be able to jump to 4.1. Release notes look like plain sailing except for snake case converters, we use our own code to do this currently, inspired from here npgsql/efcore.pg#21 but I've upgraded personal projects from that so should be doable for us here too.

@dwat001 dwat001 deleted the Issue2501_ExceptionDetailHasProductionData branch June 14, 2020 23:13
@roji roji linked an issue Jun 19, 2020 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PostgreSQL returns inserted data in exception if insert fails

3 participants