-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Image upload fails with "Cannot read properties of null" after upgrading to v2.0.0 #1516
Copy link
Copy link
Open
Open
Copy link
Labels
bugSomething isn't workingSomething isn't working
Description
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": []
- Click Save.
Root Cause Analysis:
The issue occurs because the API endpoint/answer/api/v1/siteinforeturnsnullfor extension lists instead of an empty 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": 0,
"max_attachment_size": 0,
"max_image_megapixel": 0,
"authorized_image_extensions": [],
"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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working