elastic/elasticsearch-java

Missing required property 'TransientMetadataConfig.enabled' when calling security().getRole()

WMD001 opened this issue · 1 comments

WMD001 commented

Java API client version

8.8.2

Java version

8

Elasticsearch Version

8.8.2

Problem description

An error occurs when using the following code, it will get co.elastic.clients.json.JsonpMappingException: Error deserializing co.elastic.clients.elasticsearch.security.get_role.Role: co.elastic.clients.util.MissingRequiredPropertyException: Missing required property 'TransientMetadataConfig.enabled' (JSON path: superuser.transient_metadata) (line no=1, column no=17246, offset=-1)

 GetRoleResponse getRoleResponse = client.security().getRole();

using

try(ApiTypeHelper.DisabledChecksHandle disabledChecksHandle = ApiTypeHelper.DANGEROUS_disableRequiredPropertiesCheck(true)) {
            GetRoleResponse getRoleResponse = client.security().getRole();
            return getRoleResponse.result();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

it not work and will get : Error deserializing co.elastic.clients.elasticsearch.security.get_role.Role: java.lang.NullPointerException (JSON path: superuser.transient_metadata) (line no=1, column no=17246, offset=-1)"

when use rest api /_security/role to get roles , it will return:

{
	...
	"superuser": {
		"cluster": [
			"all"
		],
		"indices": [
			{
				"names": [
					"*"
				],
				"privileges": [
					"all"
				],
				"allow_restricted_indices": false
			},
			{
				"names": [
					"*"
				],
				"privileges": [
					"monitor",
					"read",
					"view_index_metadata",
					"read_cross_cluster"
				],
				"allow_restricted_indices": true
			}
		],
		"applications": [
			{
				"application": "*",
				"privileges": [
					"*"
				],
				"resources": [
					"*"
				]
			}
		],
		"run_as": [
			"*"
		],
		"metadata": {
			"_reserved": true
		},
		"transient_metadata": {}
	}
}

role superRole is shortage of transient_metadata.enable key

Hello, thanks for the report! This was recently fixed with #756, updating the client to one of the more recent versions should solve this.