eschutho opened a new pull request, #35808:
URL: https://github.com/apache/superset/pull/35808

   ### SUMMARY
   
   Fixes an `AttributeError: 'NoneType' object has no attribute 'read'` that 
occurred when the dashboard thumbnail endpoint attempted to serve an invalid or 
corrupted BytesIO object.
   
   **Root Cause:**
   When retrieving cached thumbnail images, the endpoint would pass a BytesIO 
object to `FileWrapper`, but in some edge cases (corrupt cache, empty data, 
etc.), this object would be `None` or invalid. The error only manifested at the 
WSGI layer when attempting to read from the file, causing server errors instead 
of graceful 404 responses.
   
   **Changes:**
   - Added validation to ensure BytesIO contains actual data (nbytes > 0)
   - Reset file position with `seek(0)` before passing to FileWrapper
   - Added comprehensive exception handling with detailed error logging
   - All invalid thumbnail states now return proper 404 responses
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   N/A - Backend fix with no UI changes
   
   ### TESTING INSTRUCTIONS
   
   1. Trigger the thumbnail endpoint with a corrupted or missing cache entry:
      ```
      GET /api/v1/dashboard/44/thumbnail/{digest}/
      ```
   2. Verify the endpoint returns a 404 response instead of a 500 error
   3. Check logs for warning messages when thumbnails are invalid/empty
   4. Verify valid thumbnails still work correctly
   
   ### ADDITIONAL INFORMATION
   
   - [ ] Has associated issue:
   - [ ] Required feature flags: `THUMBNAILS` (existing)
   - [ ] Changes UI
   - [ ] Includes DB Migration
   - [ ] Introduces new feature or API
   - [ ] Removes existing feature or API
   
   🤖 Generated with [Claude Code](https://claude.com/claude-code)


-- 
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