Skip to content

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

@WMD001

Description

@WMD001

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions