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

Fix URL endpoint for injected NessieApi from OldNessieServer #7958

Merged
merged 5 commits into from Jan 16, 2024

Conversation

XN137
Copy link
Contributor

@XN137 XN137 commented Jan 16, 2024

in #7854 CurrentNessieServer was adjusted to build NessieApi instances with an URL that includes app/.
However this adjustment was missing in OldNessieServer which caused the injected NessieApi instance to use a wrong endpoint and run into HTTP 404 errors since 0.75.0.

@@ -61,7 +61,7 @@ static CurrentNessieServer currentNessieServer(

@Override
public URI getUri(Class<? extends NessieApi> apiType) {
return Util.resolveNessieUri(jersey.getUri().resolve("api/"), apiType);
return Util.resolveNessieUri(jersey.getUri(), serverKey.getVersion(), apiType);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

#7854 added api/ here but nothing version-aware in OldNessieServer

any ideas how to stay "ahead" of such problems in the future?
i.e. do we need server/client compatibility tests that use a Version.LAST_RELEASE value? then at least after a new release we might get notified.

or a test that uses Version.CURRENT with OldNessieServer somehow?

Copy link
Member

Choose a reason for hiding this comment

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

OldNessieServer relies on published jars, so it is currently at least one release behind (it cannot test main due to lack of artifacts). One option may be to do publishToMavenLocal and use those artifacts in CI.

Copy link
Member

Choose a reason for hiding this comment

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

Add the version to nessie-compatibility.properties?

Copy link
Member

@dimas-b dimas-b Jan 16, 2024

Choose a reason for hiding this comment

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

If we go with publishToMavenLocal I believe some extra changes will be required to support "snapshot" versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Add the version to nessie-compatibility.properties?

doesnt this require awareness of the developer that made the change that compatibility was broken?
CI tests should find this for the developer "automatically"

Copy link
Member

@dimas-b dimas-b Jan 16, 2024

Choose a reason for hiding this comment

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

What I'm proposing is to run publishToMavenLocal in CI and use that version for tests automatically, indeed... but let's do that in another PR (I believe it will have some ripple effect in the code that handles versions).

@snazy
Copy link
Member

snazy commented Jan 16, 2024

Please change the PR title / commit-title to what the change does where.

Copy link
Member

@dimas-b dimas-b left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Thanks for the fix @XN137 !

@XN137 XN137 changed the title NessieApi injection is broken with OldNessieServer from 0.75.0 Fix broken NessieApi injection with OldNessieServer since 0.75.0 Jan 16, 2024
@XN137 XN137 marked this pull request as ready for review January 16, 2024 14:31

// use api
List<Reference> references = api.getAllReferences().get().getReferences();
soft.assertThat(references).isNotEmpty();
Copy link
Contributor Author

@XN137 XN137 Jan 16, 2024

Choose a reason for hiding this comment

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

note that without assertNoFailedTestEvents the outer assertion for allVersions would pass just fine, even though the API usage causes an error (since it comes last)

@snazy
Copy link
Member

snazy commented Jan 16, 2024

Please change the PR title / commit-title to what the change does where.

Sorry, but can you be a bit more specific in the PR description / commit message - what's exactly broken and what's changed.

dimas-b
dimas-b previously approved these changes Jan 16, 2024
@dimas-b
Copy link
Member

dimas-b commented Jan 16, 2024

[...] PR description / commit message

Suggestion: Support /api URL suffix in OldNessieServer

@XN137 XN137 changed the title Fix broken NessieApi injection with OldNessieServer since 0.75.0 Fix URL endpoint for injected NessieApi from OldNessieServer Jan 16, 2024
@@ -131,15 +155,34 @@ void olderServers() {
soft.assertThat(OldServersSample.uris).allMatch(uri -> uri.getPath().equals("/"));
}

@Test
void injectedNessieApiUrlChanged() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

test fails like this:

Multiple Failures (1 failure)
-- failure 1 --The following test events have failed:
:Event [type = FINISHED, testDescriptor = TestMethodTestDescriptor: [engine:nessie-multi-env]/[nessie-version:0.75.0]/[class:org.projectnessie.tools.compatibility.internal.TestNessieCompatibilityExtensions$ApiEndpointServerSample]/[method:testSome()], timestamp = 2024-01-16T13:46:43.453995109Z, payload = TestExecutionResult [status = FAILED, throwable = org.projectnessie.client.rest.NessieServiceException: Not Found (HTTP/404): 

Additionally, the client-side exception below was caught while decoding the HTTP response:
com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot deserialize value of type `org.projectnessie.error.ImmutableNessieError` from [Unavailable value] (token `JsonToken.NOT_AVAILABLE`)
 at [Source: UNKNOWN; byte offset: #UNKNOWN]
	at com.fasterxml.jackson.databind.exc.MismatchedInputException.from(MismatchedInputException.java:59)
	at com.fasterxml.jackson.databind.DeserializationContext.reportInputMismatch(DeserializationContext.java:1767)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1541)
	at com.fasterxml.jackson.databind.DeserializationContext.handleUnexpectedToken(DeserializationContext.java:1488)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer._deserializeOther(BeanDeserializer.java:224)
	at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:187)
	at com.fasterxml.jackson.databind.deser.DefaultDeserializationContext.readRootValue(DefaultDeserializationContext.java:342)
	at com.fasterxml.jackson.databind.ObjectReader._bind(ObjectReader.java:2099)
	at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1249)
	at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1267)
	at com.fasterxml.jackson.databind.ObjectReader.treeToValue(ObjectReader.java:2044)
	at org.projectnessie.client.rest.ResponseCheckFilter.decodeErrorObject(ResponseCheckFilter.java:111)
	at org.projectnessie.client.rest.ResponseCheckFilter.checkResponse(ResponseCheckFilter.java:55)
	at org.projectnessie.client.rest.NessieHttpResponseFilter.filter(NessieHttpResponseFilter.java:29)
	at org.projectnessie.client.http.impl.jdk11.JavaRequest.lambda$executeRequest$1(JavaRequest.java:143)
	at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
	at java.base/java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092)
	at org.projectnessie.client.http.impl.jdk11.JavaRequest.executeRequest(JavaRequest.java:143)
	at org.projectnessie.client.http.HttpRequest.get(HttpRequest.java:106)
	at org.projectnessie.client.rest.v1.RestV1TreeClient.getAllReferences(RestV1TreeClient.java:58)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.projectnessie.client.rest.v1.RestV1Client$ExceptionRewriter.invoke(RestV1Client.java:84)
	at jdk.proxy3/jdk.proxy3.$Proxy293.getAllReferences(Unknown Source)
	at org.projectnessie.client.rest.v1.HttpGetAllReferences.get(HttpGetAllReferences.java:42)
	at org.projectnessie.client.rest.v1.HttpGetAllReferences.get(HttpGetAllReferences.java:22)
	at org.projectnessie.client.builder.BaseGetAllReferencesBuilder.get(BaseGetAllReferencesBuilder.java:70)
	at org.projectnessie.tools.compatibility.internal.TestNessieCompatibilityExtensions$ApiEndpointServerSample.testSome

@XN137
Copy link
Contributor Author

XN137 commented Jan 16, 2024

Sorry, but can you be a bit more specific in the PR description / commit message - what's exactly broken and what's changed.

updated, please make a concrete suggestion if you are still not happy.

@dimas-b dimas-b merged commit c4366af into projectnessie:main Jan 16, 2024
17 checks passed
@XN137 XN137 deleted the injected-nessieapi-problem branch January 16, 2024 18:15
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.

None yet

3 participants