# 사용자 API 키: 중복된 client\_id로 인해 내부 서버 오류 발생

**URL:** <https://meta.discourse.org/t/user-api-keys-duplicate-client-id-will-lead-to-internal-server-error/260995>\
**Category:** Bug\
**Tags:** rest-api\
**Created:** [4월 7, 2023, 11:16오후 UTC](https://meta.discourse.org/t/user-api-keys-duplicate-client-id-will-lead-to-internal-server-error/260995 "2023-04-07T23:16:23Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![Indra](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/indra/32/215866_2.png) [@Indra](https://meta.discourse.org/u/Indra)\
**Post date:** [4월 7, 2023, 11:16오후 UTC](https://meta.discourse.org/t/user-api-keys-duplicate-client-id-will-lead-to-internal-server-error/260995/1 "2023-04-07T23:16:23Z")

</div>

`client_id`가 이미 다른 사용자에 의해 사용 중인 경우 `user-api-key/new`를 호출하면 포럼은 `RecordNotUnique` 오류를 발생시키고 내부 서버 오류로 조용히 실패합니다.

 ![image](https://global.discourse-cdn.com/meta/original/4X/4/0/8/408993b0ffe9ff13cba1af7235b4a5a0d368dc62.png)

```plaintext
ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "index_user_api_keys_on_client_id"
DETAIL: Key (client_id)=(893e0230d52455ea9b729334) already exists.
)
(eval):105:in `exec_params'
app/controllers/user_api_keys_controller.rb:66:in `create'

```

이 경우 해당 클라이언트 ID를 가진 API 키가 이미 존재한다는 사실을 사용자에게 알리는 방식으로, 좀 더 명확하게 실패하도록 개선하는 것이 좋을 것 같습니다.

그러나 이는 두 번째 질문으로 이어집니다. 사용자 API 키가 이러한 방식으로 동작하도록 설계된 것인가요? 클라이언트 ID는 모든 사용자 간에 고유해야 하나요?

---

_[View the full topic](https://meta.discourse.org/t/user-api-keys-duplicate-client-id-will-lead-to-internal-server-error/260995)._
