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: handled API errors break preloaded content #3920

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

SychO9
Copy link
Member

@SychO9 SychO9 commented Nov 3, 2023

Fixes flarum/issue-archive#39

Changes proposed in this pull request:

  • Frontend content such as the Discussion page or the IndexPage run calls to the API using the internal API client. When that process errors out, it is handled by the API error handler which means we get a JSON response other than what we expect, leading to incomprehensible error pages where the frontend is broken, even when it is a simple 404 or 403 exception.
  • In this case we want the exceptions/errors not to be handled by the API client, but instead propagate to the forum/admin error handler.
  • But there are other cases where we want the client to handle the errors, such as in a testing context where we might be testing error response structure.
  • This PR adds a way to tell the client when to handle errors and when not to do so. We tell the client not to handle errors for all preloaded content.

Necessity

  • Has the problem that is being solved here been clearly explained?
  • If applicable, have various options for solving this problem been considered?
  • For core PRs, does this need to be in core, or could it be in an extension?
  • Are we willing to maintain this for years / potentially forever?

Confirmed

  • Frontend changes: tested on a local Flarum installation.
  • Backend changes: tests are green (run composer test).
  • Core developer confirmed locally this works as intended.
  • Tests have been added, or are not appropriate here.

@SychO9 SychO9 added the type/bug label Nov 3, 2023
@SychO9 SychO9 added this to the 2.0 milestone Nov 3, 2023
@SychO9 SychO9 self-assigned this Nov 3, 2023
@SychO9 SychO9 requested a review from a team as a code owner November 3, 2023 14:35
@imorland imorland merged commit 5e3f8db into 2.x Nov 10, 2023
22 checks passed
@imorland imorland deleted the sm/archive-39-api-client-error-handling branch November 10, 2023 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve API Client Error Handling
3 participants