YongJie-Xie opened a new issue, #1516:
URL: https://github.com/apache/answer/issues/1516

   ## 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:
   1. Upgrade the Answer instance to version **2.0.0**.
   2. Log in as a user.
   3. Go to create a new Question or Answer.
   4. Click the **Image Upload** icon in the editor toolbar.
   5. Select an image file to upload.
   6. 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
   <img width="538" height="90" alt="Image" 
src="https://github.com/user-attachments/assets/da26717e-5a05-4344-8ed5-92c4ba57b78c";
 />
   
   ## Platform
   - Device: Desktop
   - OS: Windows
   - Browser: Chrome latest
   - Version: v2.0.0
   
   ---
   
   ## Additional Context / Workaround
   
   **Workaround:**
   To temporarily fix this issue without redeploying:
   1. Go to **Admin** > **Advanced** > **Files**.
   2. Enter any text into `Authorized image extensions` and `Authorized 
attachment extensions`.
   3. Click **Save**.
   4. Delete the text from both fields (leave them empty).
   5. Click **Save** again.
   
   **Root Cause Analysis:**
   The issue occurs because the API endpoint `/answer/api/v1/siteinfo` returns 
`null` for extension lists instead of an empty array `[]` after a fresh upgrade.
   
   **API Response (Error State):**
   ```json
   {
     "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):**
   ```json
   {
     "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.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to