elastic / elastic/elasticsearch-specification

In POST /_security/api_key requests, the name parameter should be required

Open
#2,018 0 comments 0 reactions 0 assignees View on GitHub
wrong type
Dominant language
TypeScript
Stars
158
Forks
136
Avg merge
19h 48m
Merged PRs (30d)
54

Description

## 🐛 Wrong type

`POST /_security/api_key` request

## Definition

The `name` parameter [is required](https://www.elastic.co/guide/en/elasticsearch/reference/8.6/security-api-create-api-key.html) but is [marked as optional](https://github.com/elastic/elasticsearch-specification/blob/main/specification/security/create_api_key/SecurityCreateApiKeyRequest.ts#L38-L39).

```diff
export interface Request extends RequestBase {
query_parameters: {
refresh?: Refresh
}
body: {
/** Expiration time for the API key. By default, API keys never expire. */
expiration?: Duration
/** Specifies the name for this API key. */
- name?: Name
+ name: Name
/**
* An array of role descriptors for this API key. This parameter is optional. When it is not specified or is an empty array, then the API key will have a point in time snapshot of permissions of the authenticated user. If you supply role descriptors then the resultant permissions would be an intersection of API keys permissions and authenticated user’s permissions thereby limiting the access scope for API keys. The structure of role descriptor is the same as the request for create role API. For more details, see create or update roles API.
* @doc_id security-api-put-role
*/
role_descriptors?: Dictionary
/**
* Arbitrary metadata that you want to associate with the API key. It supports nested data structure. Within the metadata object, keys beginning with _ are reserved for system usage.
* @since 7.13.0
*/
metadata?: Metadata
}
}

Contributor guide

Open the contributing guide

Research direction

Open specification/security/create_api_key/SecurityCreateApiKeyRequest.ts and compare the request definition with the linked Create API Key documentation. Confirm that the body’s name field is required rather than optional, then run the repository’s relevant validation. Done means the TypeScript request type matches the documented API requirement.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.