Skip to content
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

Allow to disable contextual error messages in reactive rest client #23171

Merged

Conversation

TomasHofman
Copy link
Contributor

  • By default, contextual error messages are enabled.
  • Can be disabled by setting configuration property quarkus.rest-client.disable-contextual-error-messages=true, or a system property of the same name.

Fixes #22777.

Copy link
Member

@gsmet gsmet left a comment

Choose a reason for hiding this comment

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

Added a small suggestion.

@TomasHofman
Copy link
Contributor Author

Hello @geoand and @michalszynkiewicz, would you review please?

@TomasHofman TomasHofman force-pushed the disabling-contextual-error-messages branch from 80bc6c8 to ea67b5a Compare January 25, 2022 10:40
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 25, 2022

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building ea67b5a

Status Name Step Failures Logs Raw logs
Initial JDK 11 Build Build Failures Logs Raw logs

Failures

⚙️ Initial JDK 11 Build #

- Failing: extensions/resteasy-reactive/rest-client-reactive/deployment 
! Skipped: docs extensions/oidc-client-reactive-filter/deployment extensions/resteasy-reactive/rest-client-reactive-jackson/deployment and 11 more

📦 extensions/resteasy-reactive/rest-client-reactive/deployment

Failed to execute goal net.revelc.code.formatter:formatter-maven-plugin:2.17.1:validate (default) on project quarkus-rest-client-reactive-deployment: File '/home/runner/work/quarkus/quarkus/extensions/resteasy-reactive/rest-client-reactive/deployment/src/test/java/io/quarkus/rest/client/reactive/ContextualErrorMessagesTest.java' has not been previously formatted. Please format file and commit before running validation!

@TomasHofman TomasHofman force-pushed the disabling-contextual-error-messages branch from ea67b5a to fd2be39 Compare January 25, 2022 15:22
"application.properties"));

static {
System.setProperty("quarkus.rest-client.disable-contextual-error-messages", "true");
Copy link
Contributor

Choose a reason for hiding this comment

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

This is quite dangerous to be honest. Would it not work to have this in a @BeforeAll call and also unset or reset the property in an @AfterAll?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will look at that.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Regarding "dangerous", do you mean the system property could leak into other tests or is it something else? Thanks :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BeforeAll doesn't work, it looks like config root is initialized sooner still. I will try to think about it more tomorrow, in the worst case we can remove this one test...

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah exactly, I'm worried about system property leaks

Copy link
Contributor

@geoand geoand Jan 25, 2022

Choose a reason for hiding this comment

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

You can set the property in the test setup itself as you have done with other tests.

@quarkus-bot
Copy link

quarkus-bot bot commented Jan 25, 2022

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building fd2be39

Status Name Step Failures Logs Raw logs
JVM Tests - JDK 11 Build Failures Logs Raw logs
JVM Tests - JDK 11 Windows Build Failures Logs Raw logs
JVM Tests - JDK 17 Build Failures Logs Raw logs
MicroProfile TCKs Tests Verify Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ JVM Tests - JDK 11 #

- Failing: extensions/resteasy-reactive/rest-client-reactive/deployment 
! Skipped: extensions/oidc-client-reactive-filter/deployment extensions/resteasy-reactive/rest-client-reactive-jackson/deployment extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment and 9 more

📦 extensions/resteasy-reactive/rest-client-reactive/deployment

io.quarkus.rest.client.reactive.ContextualErrorMessagesTest.errorMessageContainsContext line 35 - More details - Source on GitHub

java.lang.AssertionError: 

Expecting actual:

⚙️ JVM Tests - JDK 11 Windows #

- Failing: extensions/resteasy-reactive/rest-client-reactive/deployment 
! Skipped: extensions/oidc-client-reactive-filter/deployment extensions/resteasy-reactive/rest-client-reactive-jackson/deployment extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment and 9 more

📦 extensions/resteasy-reactive/rest-client-reactive/deployment

io.quarkus.rest.client.reactive.ContextualErrorMessagesTest.errorMessageContainsContext line 35 - More details - Source on GitHub

java.lang.AssertionError: 

Expecting actual:

⚙️ JVM Tests - JDK 17 #

- Failing: extensions/resteasy-reactive/rest-client-reactive/deployment 
! Skipped: extensions/oidc-client-reactive-filter/deployment extensions/resteasy-reactive/rest-client-reactive-jackson/deployment extensions/resteasy-reactive/rest-client-reactive-kotlin-serialization/deployment and 9 more

📦 extensions/resteasy-reactive/rest-client-reactive/deployment

io.quarkus.rest.client.reactive.ContextualErrorMessagesTest.errorMessageContainsContext line 35 - More details - Source on GitHub

java.lang.AssertionError: 

Expecting actual:

⚙️ MicroProfile TCKs Tests #

- Failing: tcks/microprofile-rest-client-reactive 

📦 tcks/microprofile-rest-client-reactive

org.eclipse.microprofile.rest.client.tck.CallMultipleMappersTest.testCallsTwoProvidersWithTwoRegisteredProvider line 69 - More details - Source on GitHub

java.lang.AssertionError: The message should be sourced from class org.eclipse.microprofile.rest.client.tck.providers.TestResponseExceptionMapper expected [A 200 OK was received, but I'm throwing an exception] but found [Received: 'A 200 OK was received, but I'm throwing an exception' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

org.eclipse.microprofile.rest.client.tck.DefaultExceptionMapperTest.testLowerPriorityMapperTakesPrecedenceFromDefault line 136 - More details - Source on GitHub

java.lang.AssertionError: class org.eclipse.microprofile.rest.client.tck.providers.LowerPriorityTestResponseExceptionMapper should be in the message expected [LowerPriorityTestResponseExceptionMapper] but found [Received: 'LowerPriorityTestResponseExceptionMapper' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest.testWithOneRegisteredProvider line 75 - More details - Source on GitHub

java.lang.AssertionError: The message should be sourced from class org.eclipse.microprofile.rest.client.tck.providers.TestResponseExceptionMapper expected [A 200 OK was received, but I'm throwing an exception] but found [Received: 'A 200 OK was received, but I'm throwing an exception' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest.testWithTwoRegisteredProviders line 105 - More details - Source on GitHub

java.lang.AssertionError: The message should be sourced from class org.eclipse.microprofile.rest.client.tck.providers.TestResponseExceptionMapper expected [A 200 OK was received, but I'm throwing an exception] but found [Received: 'A 200 OK was received, but I'm throwing an exception' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

@TomasHofman TomasHofman force-pushed the disabling-contextual-error-messages branch from fd2be39 to d57a488 Compare January 26, 2022 09:44
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 26, 2022

This workflow status is outdated as a new workflow run has been triggered.

Failing Jobs - Building d57a488

Status Name Step Failures Logs Raw logs
JVM Tests - JDK 11 Build Failures Logs Raw logs
✔️ JVM Tests - JDK 17
MicroProfile TCKs Tests Verify Failures Logs Raw logs
Native Tests - Data6 Build Failures Logs Raw logs

Full information is available in the Build summary check run.

Failures

⚙️ JVM Tests - JDK 11 #

- Failing: integration-tests/grpc-hibernate 

📦 integration-tests/grpc-hibernate

com.example.grpc.hibernate.BlockingRawTest.shouldAdd line 60 - More details - Source on GitHub

org.awaitility.core.ConditionTimeoutException: Condition with lambda expression in com.example.grpc.hibernate.BlockingRawTest that uses java.util.List was not fulfilled within 30 seconds.
	at org.awaitility.core.ConditionAwaiter.await(ConditionAwaiter.java:164)
	at org.awaitility.core.CallableCondition.await(CallableCondition.java:78)

⚙️ MicroProfile TCKs Tests #

- Failing: tcks/microprofile-rest-client-reactive 

📦 tcks/microprofile-rest-client-reactive

org.eclipse.microprofile.rest.client.tck.CallMultipleMappersTest.testCallsTwoProvidersWithTwoRegisteredProvider line 69 - More details - Source on GitHub

java.lang.AssertionError: The message should be sourced from class org.eclipse.microprofile.rest.client.tck.providers.TestResponseExceptionMapper expected [A 200 OK was received, but I'm throwing an exception] but found [Received: 'A 200 OK was received, but I'm throwing an exception' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

org.eclipse.microprofile.rest.client.tck.DefaultExceptionMapperTest.testLowerPriorityMapperTakesPrecedenceFromDefault line 136 - More details - Source on GitHub

java.lang.AssertionError: class org.eclipse.microprofile.rest.client.tck.providers.LowerPriorityTestResponseExceptionMapper should be in the message expected [LowerPriorityTestResponseExceptionMapper] but found [Received: 'LowerPriorityTestResponseExceptionMapper' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest.testWithOneRegisteredProvider line 75 - More details - Source on GitHub

java.lang.AssertionError: The message should be sourced from class org.eclipse.microprofile.rest.client.tck.providers.TestResponseExceptionMapper expected [A 200 OK was received, but I'm throwing an exception] but found [Received: 'A 200 OK was received, but I'm throwing an exception' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

org.eclipse.microprofile.rest.client.tck.ExceptionMapperTest.testWithTwoRegisteredProviders line 105 - More details - Source on GitHub

java.lang.AssertionError: The message should be sourced from class org.eclipse.microprofile.rest.client.tck.providers.TestResponseExceptionMapper expected [A 200 OK was received, but I'm throwing an exception] but found [Received: 'A 200 OK was received, but I'm throwing an exception' when invoking: Rest Client method: 'org.eclipse.microprofile.rest.client.tck.interfaces.SimpleGetApi#executeGet']
	at org.testng.Assert.fail(Assert.java:96)
	at org.testng.Assert.failNotEquals(Assert.java:776)

⚙️ Native Tests - Data6 #

- Failing: integration-tests/hibernate-search-orm-elasticsearch-coordination-outbox-polling 

📦 integration-tests/hibernate-search-orm-elasticsearch-coordination-outbox-polling

Failed to execute goal io.fabric8:docker-maven-plugin:0.38.1:start (docker-start) on project quarkus-integration-test-hibernate-search-orm-elasticsearch-coordination-outbox-polling: I/O Error

@geoand
Copy link
Contributor

geoand commented Jan 28, 2022

The TCK test failures do seem related

@TomasHofman
Copy link
Contributor Author

Yes, they do, sorry for delay, will get back to this soon.

@geoand
Copy link
Contributor

geoand commented Jan 28, 2022

No rush :)

@TomasHofman
Copy link
Contributor Author

I'm still getting side tracked by different tasks, but I have this in my queue.

The issue is that current changes somehow cause that setting the quarkus.rest-client.disable-contextual-error-messages=true system property has no effect in the TCK tests, and the feature remain disabled, as if the property is false.

I couldn't figure out why the property is not seen, and I can't figure out how to debug RestClientCDIDelegateBuilder#configureCustomProperties method in the TCK tests (they are arquillian tests, and breakpoints in that method just don't catch).

Anyway, going to investigate further soon.

* By default, contextual error messages are enabled.
* Can be disabled by setting configuration property
  "quarkus.rest-client.disable-contextual-error-messages=true", or a
  system property of the same name.
@TomasHofman TomasHofman force-pushed the disabling-contextual-error-messages branch from d57a488 to 59a2e2b Compare February 2, 2022 12:02
@TomasHofman
Copy link
Contributor Author

So, situation is quite simple after all. We need to keep the system property check in RestClientRequestContext.java (https://github.com/quarkusio/quarkus/pull/23171/files#diff-d4ff9fcb3ceededf539684304aa23d72f0550f593610eeeb34cfccdc86f6de08), because the TCK tests create the clients via builder (obviously), therefore anything we do with config roots will be bypassed. Also we have no option (I guess) to modify the test code itself. I updated the PR accordingly.

@geoand
Copy link
Contributor

geoand commented Feb 2, 2022

Gotcha, thanks!

@geoand geoand merged commit b42be6d into quarkusio:main Feb 2, 2022
@quarkus-bot quarkus-bot bot added this to the 2.8 - main milestone Feb 2, 2022
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.

Rest-Client-Reactive: Allow disabling contextual error messages
3 participants