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

Fix error message for forbidden error #149

Merged
merged 1 commit into from
Jun 14, 2024
Merged

Fix error message for forbidden error #149

merged 1 commit into from
Jun 14, 2024

Conversation

wataru86
Copy link
Member

@wataru86 wataru86 commented Jun 7, 2024

What

  • publish コマンドで API が Forbidden を返した際のエラーメッセージを修正しました。
before after
image image

Why

  • 記事ファイルに不備がある場合に API が Forbidden を返す可能性があるため。
      • private を false から true に変更しようとしたとき
      • タグにスペースが含まれているとき

Refs

@wataru86 wataru86 requested review from a team and tomoasleep and removed request for a team June 7, 2024 03:07
Copy link
Member

@tomoasleep tomoasleep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

記事ファイルに不備がある場合に API が Forbidden を返す可能性があるため。

    • private を false から true に変更しようとしたとき
    • タグにスペースが含まれているとき

この例を見る感じ、クライアント側で対処するのではなく、そもそも API が返す status code が適切ではないのでは?ということを思いました。 (400 とか 422 とかを返すべきなのでは?ということを思いました。)

src/lib/error-handler.ts は、名前からして汎用的な処理で、 API のエラーに対して、汎用的なエラーメッセージを返す場所なので、 status code の意味と明らかに異なるメッセージを返すのは避けたいです。

(基本的には API 側で対処してほしいですが、) 一時的にクライアントで対応するにしても、汎用的なエラーメッセージの表示箇所ではなく、 command 単位でエラーメッセージの表示を変更するか (TODO コメント付きで)、クライアント validation などをするかしてください。

@wataru86 wataru86 self-assigned this Jun 12, 2024
@wataru86 wataru86 requested a review from tomoasleep June 12, 2024 03:19
@wataru86
Copy link
Member Author

@tomoasleep リマインドです。レビューお願いします 🙏

Copy link
Member

@tomoasleep tomoasleep left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • API 側の問題はいずれ対応予定
  • 先にクライアント側のエラー通知を改善しておきたい

ということで、問題がある API を使用している箇所のみエラーメッセージを変更することにした。LGTM 👍

@tomoasleep
Copy link
Member

メモ: xt0rted/block-autosquash-commits-action@v2 でテストがスキップされてるが、 public repo ではスキップは不要だと思う。

@wataru86 wataru86 merged commit 4f0e2e8 into main Jun 14, 2024
6 checks passed
@wataru86 wataru86 deleted the fix-error-message branch June 14, 2024 03:19
@wataru86 wataru86 mentioned this pull request Jun 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants