[Admin][Backend] Cannot edit the `Alternative Text` field on a product's image
Solidus Version: 2.9.0
To Reproduce
- Go to
/store/admin/products/[A-PRODUCT-ID]/images - Edit the
Alternative Textfield of an existing image - The
Loading...loader shows up and stays indefinitely
TypeError: response.responseJSON is undefined
Current behavior
The Loading... loader shows up and stays indefinitely. When refreshing the page, the Alternative Text field has not been updated
Expected behavior
The Loading... loader shows up and eventually disappears. When refreshing the page, the Alternative Text field has been updated
Screenshots
Desktop (please complete the following information):
- OS: Mac OS Mojave 10.14.6
- Browser: Mozilla Firefox Developer Edition
- Version: 71.0b7 (64 bits)
Additional context
- Getting a
TypeError: response.responseJSON is undefinedJS error in the browser console - Creating an image with an
Alternative Textvalue works fine.
Hi @EmCousin! I tested this scenario in the following versions: 2.10 and 2.9 and I couldn't reproduce it.

Desktop
- OS: Mac OS Catalina 10.15.2
- Browser: Mozilla Firefox
- Version: 73.0.1 (64 bits)
Did you customize the JS in your Solidus Admin? or Did you upgrade from a previous version?
Hi @jaimelr,
It turns out I had overriden the Spree::Api::BaseController to add a before_action :authenticate_token! callback. That callback returns head :unauthorized when the authentication fails (which is actually the case in the context of this issue), i.e. no JSON response that can be properly parsed by this line, therefore triggering the JS error TypeError: response.responseJSON is undefined
Editing that line to something like show_flash('error', response.responseJSON && response.responseJSON.error || "An error occurred"); would do the trick. If you agree, I can push a PR?
Awesome! Well, makes sense to add a default error message here but I'll let maybe @kennyadsl decide if it worth at this moment. 🙂
@SamuelMartini what do you think about this one in terms of API consistency with the rest of Solidus? If unauthorized maybe we can avoid showing the feature at all also?