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

   ### SUMMARY
   
   Older database forms stored the catalog/schema/table metadata cache timeouts 
in `extra.metadata_cache_timeout` as strings (e.g. `"schema_cache_timeout": 
"3600"`). With cachelib 0.17 those values reach the cache backend, which raises 
`TypeError: timeout must be an int or datetime.timedelta, got 'str'`, so SQL 
Lab schema and table lists fail for affected databases (#45460).
   
   The API schema already rejects new string values, so only legacy stored rows 
are affected. This change makes the model accessors (`catalog_cache_timeout`, 
`schema_cache_timeout`, `table_cache_timeout`) read a string of ASCII digits as 
its integer value. Any other non-integer value (empty or malformed strings, 
negative numbers, booleans) falls back to the default timeout, with a warning 
naming the key and database id (never the value). Integer values are returned 
unchanged, and the `*_cache_enabled` properties are unchanged.
   
   This complements #45790, which normalizes the stored values with a migration 
on master. This fix needs no migration, so it can be backported to the 7.0 
release branch, where #45790's migration can't go because its `down_revision` 
chains off master-only revisions. With both in place, the accessor guard also 
covers rows that the migration conservatively skips.
   
   ### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
   
   Not applicable.
   
   ### TESTING INSTRUCTIONS
   
   - `pytest tests/unit_tests/models/core_test.py -k cache`: the new 
parametrized test covers all three accessors with integer, digit-string, empty, 
malformed, negative, whitespace-padded, non-ASCII digit, boolean and null 
values. 24 of its 33 cases fail without the fix.
   - Manually: set a database's `extra` to `{"metadata_cache_timeout": 
{"schema_cache_timeout": "600"}}` directly in the metadata DB, then open SQL 
Lab and load that database's schemas and tables. Before: a 500 with the 
`TypeError` above. After: the lists load and are cached for 600 seconds.
   
   ### ADDITIONAL INFORMATION
   
   - [x] Has associated issue: Fixes #45460
   - [ ] 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]

Reply via email to