Describe the bug
After upgrading from a previous version to Answer v2.0.0, attempting to upload an image triggers a runtime exception, and the upload fails. The browser console reports the error: Cannot read properties of null.
To Reproduce
Steps to reproduce the behavior:
- Upgrade the Answer instance to version 2.0.0.
- Log in as a user.
- Go to create a new Question or Answer.
- Click the Image Upload icon in the editor toolbar.
- Select an image file to upload.
- See the error in the console and observe that the image does not appear.
Expected behavior
The image should upload successfully and display in the editor.
Screenshots
Platform
- Device: Desktop
- OS: Windows
- Browser: Chrome latest
- Version: v2.0.0
Additional Context / Workaround
Workaround:
To temporarily fix this issue without redeploying:
- Go to Admin > Advanced > Files.
- Default configuration:
max_image_size: 4
max_attachment_size: 8
max_image_megapixel: 40
authorized_image_extensions: jpg, jpeg, png, gif, webp
authorized_attachment_extensions: <- empty
- Click Save.
Root Cause Analysis:
The issue occurs because the API endpoint /answer/api/v1/siteinfo returns null for extension lists instead of an array after a fresh upgrade.
API Response (Error State):
{
"site_advanced": {
"max_image_size": 0,
"max_attachment_size": 0,
"max_image_megapixel": 0,
"authorized_image_extensions": null,
"authorized_attachment_extensions": null
}
}
API Response (After Workaround):
{
"site_advanced": {
"max_image_size": 4,
"max_attachment_size": 8,
"max_image_megapixel": 40,
"authorized_image_extensions": [
"jpg",
"jpeg",
"png",
"gif",
"webp"
],
"authorized_attachment_extensions": []
}
}
Code Analysis:
The error is triggered in src/components/Editor/hooks/useImageUpload.ts. The code attempts to check authorized_attachment_extensions.length > 0. Since the value is null, accessing the .length property throws the exception.
Describe the bug
After upgrading from a previous version to Answer v2.0.0, attempting to upload an image triggers a runtime exception, and the upload fails. The browser console reports the error:
Cannot read properties of null.To Reproduce
Steps to reproduce the behavior:
Expected behavior
The image should upload successfully and display in the editor.
Screenshots
Platform
Additional Context / Workaround
Workaround:
To temporarily fix this issue without redeploying:
Root Cause Analysis:
The issue occurs because the API endpoint
/answer/api/v1/siteinforeturnsnullfor extension lists instead of an array after a fresh upgrade.API Response (Error State):
{ "site_advanced": { "max_image_size": 0, "max_attachment_size": 0, "max_image_megapixel": 0, "authorized_image_extensions": null, "authorized_attachment_extensions": null } }API Response (After Workaround):
{ "site_advanced": { "max_image_size": 4, "max_attachment_size": 8, "max_image_megapixel": 40, "authorized_image_extensions": [ "jpg", "jpeg", "png", "gif", "webp" ], "authorized_attachment_extensions": [] } }Code Analysis:
The error is triggered in
src/components/Editor/hooks/useImageUpload.ts. The code attempts to checkauthorized_attachment_extensions.length > 0. Since the value isnull, accessing the.lengthproperty throws the exception.