Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

アクセス権絡みのエラーが発生した時もKintoneRestAPIError#errorsが欲しい #13

Open
the-red opened this issue Dec 2, 2020 · 1 comment
Labels
feature request Feature request pkg: rest-api-client @kintone/rest-api-client

Comments

@the-red
Copy link

the-red commented Dec 2, 2020

Package(対象パッケージ)

  • @kintone/rest-api-client

Why(なぜ)

update権限がないレコードに対してupdateRecord()した場合など、
アクセス権に問題があるときは403エラーが返ってきますが、
エラーオブジェクトにerrorsmessageもないため、エラー原因をぱっと見で確認するのが難しいです。
(エンジニアなら分かっても、一般ユーザーには分からないです。)

{
  "name": "KintoneRestAPIError",
  "id": "veh9IwUXQwn0wstIvhrv",
  "code": "CB_NO02",
  "status": 403,
  "headers": {
    "cache-control": "no-cache, no-store, must-revalidate",
    "connection": "keep-alive",
    "content-encoding": "gzip",
    "content-type": "application/json;charset=utf-8",
    "date": "Wed, 02 Dec 2020 02:03:51 GMT",
    "server": "nginx",
    "strict-transport-security": "max-age=315360000; includeSubDomains; preload;",
    "transfer-encoding": "chunked",
    "vary": "Accept-Encoding",
    "x-concurrencylimit-limit": "100",
    "x-concurrencylimit-running": "1",
    "x-content-type-options": "nosniff",
    "x-cybozu-error": "GAIA_BR01",
    "x-frame-options": "SAMEORIGIN",
    "x-ua-compatible": "IE=Edge",
    "x-xss-protection": "1; mode=block"
  }
}

kintoneからのレスポンスに、そもそもerrors相当のものがないのだと思いますが、
せっかくSDKでラップしてもらっているので、
kintone APIエラーメッセージが気が利かない部分も吸収していただけると助かります。

エラーが起きた時、ユーザーにerrorsの内容をアラートで表示してあげることが多いので、
ユーザーに日本語でエラーを見せるには、
「403の時はアクセス権がありませんという文章を出す」みたいなロジックが必要です。
自分で実装するよりは、SDK側で対応してもらえると有り難いのです。

What(何を)

ちょっとした日本語で良いので、
code, statusに対応するメッセージが出ると良いですね。

アクセス権以外にもメッセージ無しのエラーはあるかもしれませんが、未確認です。

{
  "name": "KintoneRestAPIError",
  "id": "veh9IwUXQwn0wstIvhrv",
  "code": "CB_NO02",
  "errors": {
    "message": "アクセス権がありません。"
  },
  "status": 403,
  "headers": {
    "cache-control": "no-cache, no-store, must-revalidate",
    "connection": "keep-alive",
    "content-encoding": "gzip",
    "content-type": "application/json;charset=utf-8",
    "date": "Wed, 02 Dec 2020 02:03:51 GMT",
    "server": "nginx",
    "strict-transport-security": "max-age=315360000; includeSubDomains; preload;",
    "transfer-encoding": "chunked",
    "vary": "Accept-Encoding",
    "x-concurrencylimit-limit": "100",
    "x-concurrencylimit-running": "1",
    "x-content-type-options": "nosniff",
    "x-cybozu-error": "GAIA_BR01",
    "x-frame-options": "SAMEORIGIN",
    "x-ua-compatible": "IE=Edge",
    "x-xss-protection": "1; mode=block"
  }
}
@zaki-yama
Copy link
Contributor

@the-red
フィードバックありがとうございます!
REST APIのレスポンスで至らない部分をクライアント側で吸収してほしい、というご意見はごもっともですので、
今回のアクセス権エラー以外のエラーも含めて、ユーザーフレンドリーなメッセージを統一的な方法で取得できるよう
検討いたします。

@zaki-yama zaki-yama added pkg: rest-api-client @kintone/rest-api-client feature request Feature request labels Mar 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Feature request pkg: rest-api-client @kintone/rest-api-client
Projects
None yet
Development

No branches or pull requests

2 participants