You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2025/06/16 20:02:25 UTC

(superset) branch master updated: fix: ensure numeric values for extra metadata_cache_timeout payloads (#28737)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 4d6cdf4fea fix: ensure numeric values for extra metadata_cache_timeout payloads (#28737)
4d6cdf4fea is described below

commit 4d6cdf4fea44164e5953357ceceb44c93cdee8e3
Author: Kidus Makonnen <ki...@gmail.com>
AuthorDate: Mon Jun 16 23:02:18 2025 +0300

    fix: ensure numeric values for extra metadata_cache_timeout payloads (#28737)
---
 .../src/features/databases/DatabaseModal/index.test.tsx    | 14 +++++++-------
 .../src/features/databases/DatabaseModal/index.tsx         |  3 +--
 2 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx
index 4a0dd068d6..d3f2f0f78a 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx
+++ b/superset-frontend/src/features/databases/DatabaseModal/index.test.tsx
@@ -1727,40 +1727,40 @@ describe('dbReducer', () => {
   test('it will set state to payload from extra input change when schema_cache_timeout', () => {
     const action: DBReducerActionType = {
       type: ActionType.ExtraInputChange,
-      payload: { name: 'schema_cache_timeout', value: 'bar' },
+      payload: { name: 'schema_cache_timeout', value: '10' },
     };
     const currentState = dbReducer(databaseFixture, action);
 
     // extra should be serialized
     expect(currentState).toEqual({
       ...databaseFixture,
-      extra: '{"metadata_cache_timeout":{"schema_cache_timeout":"bar"}}',
+      extra: '{"metadata_cache_timeout":{"schema_cache_timeout":10}}',
     });
   });
 
   test('it will set state to payload from extra input change when table_cache_timeout', () => {
     const action: DBReducerActionType = {
       type: ActionType.ExtraInputChange,
-      payload: { name: 'table_cache_timeout', value: 'bar' },
+      payload: { name: 'table_cache_timeout', value: '10' },
     };
     const currentState = dbReducer(databaseFixture, action);
 
     // extra should be serialized
     expect(currentState).toEqual({
       ...databaseFixture,
-      extra: '{"metadata_cache_timeout":{"table_cache_timeout":"bar"}}',
+      extra: '{"metadata_cache_timeout":{"table_cache_timeout":10}}',
     });
   });
 
   test('it will overwrite state to payload from extra input change when table_cache_timeout', () => {
     const action: DBReducerActionType = {
       type: ActionType.ExtraInputChange,
-      payload: { name: 'table_cache_timeout', value: 'bar' },
+      payload: { name: 'table_cache_timeout', value: '10' },
     };
     const currentState = dbReducer(
       {
         ...databaseFixture,
-        extra: '{"metadata_cache_timeout":{"table_cache_timeout":"foo"}}',
+        extra: '{"metadata_cache_timeout":{"table_cache_timeout":5}}',
       },
       action,
     );
@@ -1768,7 +1768,7 @@ describe('dbReducer', () => {
     // extra should be serialized
     expect(currentState).toEqual({
       ...databaseFixture,
-      extra: '{"metadata_cache_timeout":{"table_cache_timeout":"bar"}}',
+      extra: '{"metadata_cache_timeout":{"table_cache_timeout":10}}',
     });
   });
 
diff --git a/superset-frontend/src/features/databases/DatabaseModal/index.tsx b/superset-frontend/src/features/databases/DatabaseModal/index.tsx
index 8b359cc141..aefea14d4e 100644
--- a/superset-frontend/src/features/databases/DatabaseModal/index.tsx
+++ b/superset-frontend/src/features/databases/DatabaseModal/index.tsx
@@ -286,7 +286,6 @@ export function dbReducer(
         }),
       };
     case ActionType.ExtraInputChange:
-      // "extra" payload in state is a string
       if (
         action.payload.name === 'schema_cache_timeout' ||
         action.payload.name === 'table_cache_timeout'
@@ -297,7 +296,7 @@ export function dbReducer(
             ...extraJson,
             metadata_cache_timeout: {
               ...extraJson?.metadata_cache_timeout,
-              [action.payload.name]: action.payload.value,
+              [action.payload.name]: Number(action.payload.value),
             },
           }),
         };