Skip to content

[improvement] Safe log missing parameters#125

Merged
bulldozer-bot[bot] merged 4 commits into
developfrom
jellis/safeLog
Jan 9, 2019
Merged

[improvement] Safe log missing parameters#125
bulldozer-bot[bot] merged 4 commits into
developfrom
jellis/safeLog

Conversation

@ellisjoe
Copy link
Copy Markdown
Contributor

Before this PR

Errors during object construction would throw an IllegalArgumentException with the missing fields included in the message. This message is excluded when the logs are collected.

After this PR

Throw a SafeIllegalArgumentException with the missing fields in a SafeArg so the missing fields are included during collection.

@ellisjoe ellisjoe requested a review from a team as a code owner November 30, 2018 19:52
@ellisjoe ellisjoe requested a review from iamdanfox November 30, 2018 20:11
Comment thread conjure-java-core/build.gradle Outdated
compile 'com.google.guava:guava'
compile 'com.palantir.conjure.java.api:errors'
compile 'com.palantir.ri:resource-identifier'
compile 'com.palantir.safe-logging:preconditions'
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.

I think we'd need to add this to the :conjure-lib project to make sure the class is available for all users.

Comment thread conjure-java-core/build.gradle Outdated

integrationInputCompile project(':conjure-lib')
integrationInputCompile 'com.palantir.conjure.java.api:errors'
integrationInputCompile 'com.palantir.safe-logging:preconditions'
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.

I don't want people to have to manually add this dependency!

Copy link
Copy Markdown
Contributor

@iamdanfox iamdanfox left a comment

Choose a reason for hiding this comment

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

This looks great! The unnecessary redaction was irritating before.

@iamdanfox
Copy link
Copy Markdown
Contributor

Only downside I can see is this does bloat all conjure-generated projects slightly by adding the safe-logging:preconditions jar (and its transitive deps).

.hasMessage("Some required fields have not been set: [binary]");
assertThatLoggableExceptionThrownBy(() -> mapper.readValue("{}", BinaryExample.class).getBinary())
.isInstanceOf(SafeIllegalArgumentException.class)
.hasMessage("Some required fields have not been set")
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.

After safe-logging is update this assertion will fail because it checks the rendered throwable message rather than the safe log message.

@carterkozak
Copy link
Copy Markdown
Contributor

Love it

@carterkozak
Copy link
Copy Markdown
Contributor

I've updated this PR, should be good to go.

@bulldozer-bot bulldozer-bot Bot merged commit de399f5 into develop Jan 9, 2019
@bulldozer-bot bulldozer-bot Bot deleted the jellis/safeLog branch January 9, 2019 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants