misskey-dev / misskey

🌎 A completely free and open interplanetary microblogging platform 🚀
https://misskey-hub.net/
GNU Affero General Public License v3.0
10.14k stars 1.38k forks source link

既にロールがついているユーザーに同じロールをつけると500エラーが返ってくる #10189

Open kabo2468 opened 1 year ago

kabo2468 commented 1 year ago

💡 Summary

{
    "e": {
        "message": "duplicate key value violates unique constraint \"IDX_0953deda7ce6e1448e935859e5\"",
        "code": "QueryFailedError",
        "stack": "QueryFailedError: duplicate key value violates unique constraint \"IDX_0953deda7ce6e1448e935859e5\"\n    at PostgresQueryRunner.query (/misskey/node_modules/.pnpm/typeorm@0.3.11_ioredis@4.28.5+pg@8.9.0/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:211:19)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async InsertQueryBuilder.execute (/misskey/node_modules/.pnpm/typeorm@0.3.11_ioredis@4.28.5+pg@8.9.0/node_modules/typeorm/query-builder/InsertQueryBuilder.js:106:33)\n    at async file:///misskey/packages/backend/built/server/api/endpoints/admin/roles/assign.js:69:29\n    at async ApiCallService.call (file:///misskey/packages/backend/built/server/api/ApiCallService.js:275:16)"
    }
}

クエリエラーではなく既にロールがついているというエラーを返すべき

🥰 Expected Behavior

既にロールがついているエラーが返ってくる

🤬 Actual Behavior

クエリエラーが返ってくる

📝 Steps to Reproduce

1.ユーザーにロールをつける 2.同じロールをつける 3.エラー

📌 Environment

Misskey version: v13~ Your OS: Windows10 Your browser: Vivaldi

syuilo commented 1 year ago

v13~ となっていますが、これは13.9.0などでも再現するということですか?

nenohi commented 1 year ago

v13.9.1ですが下記エラーになります image

Endpoint: admin/roles/assign
Info: {"e":{"message":"","code":"Error","id":"1004dcb9-14d3-4cd0-acf6-e3f099504a66"}}
Date: 2023-03-04T01:54:54.445Z
fruitriin commented 1 year ago

げむすきでもみすてむでもおきますね

kabo2468 commented 1 year ago

v13.9.1(ローカル)でサーバーログにはこれが出てる Error投げてるけど内容がない

{
  ep: 'admin/roles/assign',
  ps: {
    roleId: '9bszlb8a0y',
    userId: '8vs4yiyhlt',
    expiresAt: null,
    i: 'TOKEN'
  },
  e: {
    message: '',
    code: 'Error',
    stack: 'Error\n' +
      '    at RoleService1.assign (file:///H:/Works/misskey/packages/backend/built/core/RoleService.js:301:23)\n' +
      '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +
      '    at async file:///H:/Works/misskey/packages/backend/built/server/api/endpoints/admin/roles/assign.js:87:13\n' +
      '    at async ApiCallService.call (file:///H:/Works/misskey/packages/backend/built/server/api/ApiCallService.js:262:16)',
    id: '8dbbf79a-1dab-414e-ad82-142cdd89a2eb'
  }
}

https://github.com/misskey-dev/misskey/blob/b23a9b1a88f481c50fc9c8f126608b90fab18266/packages/backend/src/core/RoleService.ts#L61