-
Notifications
You must be signed in to change notification settings - Fork 320
Closed
Description
This is in reference to promregator/promregator#36, where the following situation has happened:
- CF platform running on API version 2.94.0
- Client application using cf-java-client 3.3.0.RELEASE -- source code as of state tested can be reviewed at https://github.com/promregator/promregator/tree/31b001aecf1e9223a2fc0794bd2f725ca87a8e00
- The interesting code part is at https://github.com/promregator/promregator/blob/31b001aecf1e9223a2fc0794bd2f725ca87a8e00/src/main/java/org/cloudfoundry/promregator/cfaccessor/CFAccessorImpl.java#L34
- Client application fires an
organizationsV3().list()request, selecting a single known org there. Aim is to get the org's ID. - The Org, however, was created somewhere at 2016-07-26T17:01:24Z. In the response, the
updatedAtis apparently nullified. - Error message (symptom), which is raised, reads:
Caused by: java.lang.IllegalStateException: Cannot build OrganizationResource, some of required attributes are not set [updatedAt]
at org.cloudfoundry.client.v3.organizations.OrganizationResource$Builder.build(OrganizationResource.java:395) ~[cloudfoundry-client-3.3.0.RELEASE.jar!/:3.3.0.RELEASE]
at org.cloudfoundry.client.v3.organizations.OrganizationResource.fromJson(OrganizationResource.java:200) ~[cloudfoundry-client-3.3.0.RELEASE.jar!/:3.3.0.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_162]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_162]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_162]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_162]
at com.fasterxml.jackson.databind.introspect.AnnotatedMethod.call1(AnnotatedMethod.java:114) ~[jackson-databind-2.9.4.jar!/:2.9.4]
at com.fasterxml.jackson.databind.deser.std.StdValueInstantiator._createUsingDelegate(StdValueInstantiator.java:525) ~[jackson-databind-2.9.4.jar!/:2.9.4]
... 70 common frames omitted
2018-03-29 22:02:08.018 ERROR 10 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.cloudfoundry.reactor.util.JsonParsingException: Cannot construct instance of `org.cloudfoundry.client.v3.organizations.OrganizationResource`, problem: Cannot build OrganizationResource, some of required attributes are not set [updatedAt]
at [Source: (byte[])"{
"pagination": {
"total_results": 1,
"total_pages": 1,
"first": {
"href": "https://my.cf.api.com/v3/organizations?names=My-CF-Org&page=1&per_page=50"
},
"last": {
"href": "https://my.cf.api.com/v3/organizations?names=My-CF-Org&page=1&per_page=50"
},
"next": null,
"previous": null
},
"resources": [
{
"guid": "ac4d8f82-c606-44cf-bda5-6fa36e01bf20",
"created_at": "2016-07-26T17:0"[truncated 248 bytes]; line: 25, column: 5] (through reference chain: org.cloudfoundry.client.v3.organizations.ListOrganizationsResponse$Json["resources"]->java.util.ArrayList[0])] with root cause
- When requesting the same org via the
organizationsV2API, the nullifiedupdatedAtattribute becomes visible (output ofcf -v orgs):
{
"next_url": null,
"prev_url": null,
"resources": [
{
"entity": {
"app_events_url": "/v2/organizations/my-org-guid/app_events",
"auditors_url": "/v2/organizations/my-org-guid/auditors",
"billing_enabled": false,
"billing_managers_url": "/v2/organizations/my-org-guid/billing_managers",
"default_isolation_segment_guid": null,
"domains_url": "/v2/organizations/my-org-guid/domains",
"managers_url": "/v2/organizations/my-org-guid/managers",
"name": "My-Org",
"private_domains_url": "/v2/organizations/my-org-guid/private_domains",
"quota_definition_guid": "my-quota-guid",
"quota_definition_url": "/v2/quota_definitions/my-quota-guid",
"space_quota_definitions_url": "/v2/organizations/my-org-guid/space_quota_definitions",
"spaces_url": "/v2/organizations/my-org-guid/spaces",
"status": "active",
"users_url": "/v2/organizations/my-org-guid/users"
},
"metadata": {
"created_at": "2016-07-26T17:01:24Z",
"guid": "my-org-guid",
"updated_at": null,
"url": "/v2/organizations/my-org-guid"
}
}
],
"total_pages": 1,
"total_results": 1
}
Further details can also be found at the linked issue above.
My expectation would have been that the V3 organization API is capable of handling this case. If the updatedAt field is really considered mandatory, then I would have expected that it would be defaulted with the value of createdAt, which apparently is available.
Case is not urgent, but something that might be worthwhile to look at - and perhaps covered in a beasty regression test...
Thanks for checking!