carlosribeiro-plaid opened a new pull request, #41530:
URL: https://github.com/apache/superset/pull/41530
### SUMMARY
`superset compute-thumbnails` crashes with `DetachedInstanceError` when more
than one model is processed (e.g. `superset compute-thumbnails -d -i 8 -i 12`).
`compute_generic_thumbnail` queries the models, then inside the loop builds
the progress message with an f-string that interpolates the ORM instance
(`f'... "{model}" ...'`). Computing a thumbnail (`cache_dashboard_thumbnail` /
`cache_chart_thumbnail`) can close/expire the SQLAlchemy session, so on the
next iteration the instance is detached and `str(model)` raises:
```
sqlalchemy.orm.exc.DetachedInstanceError: Instance <Dashboard at 0x...> is
not bound to a Session; attribute refresh operation cannot proceed
```
The fix materializes the `(id, label)` pairs up front, before any thumbnail
is computed, then iterates over plain values — so the loop never touches a
detached ORM instance. No behavior change otherwise.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A (CLI bug fix).
### TESTING INSTRUCTIONS
1. With thumbnails enabled, run `superset compute-thumbnails -d -i <id1> -i
<id2>` (two or more ids).
2. Before: it processes the first model, then crashes with
`DetachedInstanceError`.
3. After: all requested models are processed.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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]