It fails with this message:
** Expected the field authorization_code_grant_access_token_lifespan to be a primitive type in the JSON string but got null
The response contains a null for this property indeed.
Inspecting the openapi in the client it reveals that type in the client is defined to be a string (not nullable) while the browsable API that is used by hydra service specifies NullDuration (which is null or a string (with a pattern)).
Hence there is a mismatch between the API that the client is generated from and the one served by hydra service.
Service has this defined type:
"authorization_code_grant_access_token_lifespan": {
"$ref": "#/components/schemas/NullDuration"
},
While client openapi.yaml has this definition:
authorization_code_grant_access_token_lifespan:
description: "Specify a time duration in milliseconds, seconds, minutes,\
\ hours."
pattern: "^([0-9]+(ns|us|ms|s|m|h))*$"
title: Time duration
type: string
Reproducing the bug
Run docker run -d --restart=always --network $NETWORK --name "..." -v $DIRECTORY/$1-dir:/workdir -p 127.0.0.1:$EXP_PUB_PORT:4444 -p 127.0.0.1:$EXP_ADM_PORT:4445 $HYDRA_IMAGE serve all -c /workdir/hydra.yaml --dev
Generate a client: docker run --rm -it --network $NETWORK $HYDRA_IMAGE create client ...
java.lang.IllegalArgumentException: Expected the field `authorization_code_grant_access_token_lifespan` to be a primitive type in the JSON string but got `null`
at sh.ory.hydra.model.OAuth2Client.validateJsonObject(OAuth2Client.java:1564) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.model.OAuth2LoginRequest.validateJsonObject(OAuth2LoginRequest.java:428) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.model.OAuth2LoginRequest$CustomTypeAdapterFactory$1.read(OAuth2LoginRequest.java:474) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.model.OAuth2LoginRequest$CustomTypeAdapterFactory$1.read(OAuth2LoginRequest.java:464) ~[hydra-client-2.0.2.jar:na]
at com.google.gson.TypeAdapter$1.read(TypeAdapter.java:201) ~[gson-2.10.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1214) ~[gson-2.10.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1124) ~[gson-2.10.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1034) ~[gson-2.10.jar:na]
at com.google.gson.Gson.fromJson(Gson.java:1001) ~[gson-2.10.jar:na]
at sh.ory.hydra.JSON.deserialize(JSON.java:186) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.ApiClient.deserialize(ApiClient.java:957) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.ApiClient.handleResponse(ApiClient.java:1165) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.ApiClient.execute(ApiClient.java:1089) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.api.OAuth2Api.getOAuth2LoginRequestWithHttpInfo(OAuth2Api.java:1402) ~[hydra-client-2.0.2.jar:na]
at sh.ory.hydra.api.OAuth2Api.getOAuth2LoginRequest(OAuth2Api.java:1381) ~[hydra-client-2.0.2.jar:na]
at no.uso.unison.backend.web.provider.LoginHydraController.getLogin(LoginHydraController.java:51) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:64) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:564) ~[na:na]
at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:205) ~[spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:150) ~[spring-web-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:117) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:808) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1067) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:963) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006) ~[spring-webmvc-5.3.20.jar:5.3.20]
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:898) ~[spring-webmvc-5.3.20.jar:5.3.20]
Relevant configuration
No response
Version
2.0.2
On which operating system are you observing this issue?
Preflight checklist
Describe the bug
Running ORY Hydra v2.0.2 in Docker. Created clients
Running my provider backend in Java. Installed generated hydra-client-java also v2.0.2
On call triggered by client starting auth:
It fails with this message: ** Expected the field
authorization_code_grant_access_token_lifespan
to be a primitive type in the JSON string but gotnull
The response contains a null for this property indeed.Inspecting the openapi in the client it reveals that type in the client is defined to be a string (not nullable) while the browsable API that is used by hydra service specifies NullDuration (which is null or a string (with a pattern)).
Hence there is a mismatch between the API that the client is generated from and the one served by hydra service.
Service has this defined type: "authorization_code_grant_access_token_lifespan": { "$ref": "#/components/schemas/NullDuration" },
While client openapi.yaml has this definition: authorization_code_grant_access_token_lifespan: description: "Specify a time duration in milliseconds, seconds, minutes,\ \ hours." pattern: "^([0-9]+(ns|us|ms|s|m|h))*$" title: Time duration type: string
Reproducing the bug
Run docker run -d --restart=always --network $NETWORK --name "..." -v $DIRECTORY/$1-dir:/workdir -p 127.0.0.1:$EXP_PUB_PORT:4444 -p 127.0.0.1:$EXP_ADM_PORT:4445 $HYDRA_IMAGE serve all -c /workdir/hydra.yaml --dev
Generate a client: docker run --rm -it --network $NETWORK $HYDRA_IMAGE create client ...
Use the java SDK (hydra-client-java), follow the implementation patterns from https://www.ory.sh/docs/hydra/concepts/login
Start a client auth flow
Relevant log output
Relevant configuration
No response
Version
2.0.2
On which operating system are you observing this issue?
Windows
In which environment are you deploying?
Docker
Additional Context
No response