Vitor-Avila opened a new issue, #24662:
URL: https://github.com/apache/superset/issues/24662

   When a dataset is created, its `extra` value is `null`. If you apply a value 
to the `extra` field, and then later remove the value (through the UI), then it 
becomes an empty string (`extra: ""`). During the import, the application 
validates if the `extra` value is a string, and if so loads it as a dictionary, 
which would fail in case it's an empty string. 
   
   #### How to reproduce the bug
   
   1. Edit an existing dataset.
   2. Add any information to the `extra` value (in the UI).
   3. Save changes.
   4. Modify the dataset again.
   5. Remove your text changes.
   6. Save changes. The dataset now has `extra: ""`.
   7. Export the dataset.
   8. Import it back.
   
   ### Expected results
   The import operation should work properly.
   
   ### Actual results
   The import operation fails: 
   
![image](https://github.com/apache/superset/assets/96086495/abcd8e52-021f-41b6-aeb6-55c187ad0731)
   
   Stack trace:
   ```
   Traceback (most recent call last):
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/flask/app.py",
 line 1823, in full_dispatch_request
       rv = self.dispatch_request()
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/flask/app.py",
 line 1799, in dispatch_request
       return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/flask_appbuilder/security/decorators.py",
 line 95, in wraps
       return f(self, *args, **kwargs)
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/views/base_api.py", 
line 127, in wraps
       raise ex
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/views/base_api.py", 
line 121, in wraps
       duration, response = time_function(f, self, *args, **kwargs)
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/utils/core.py", line 
1523, in time_function
       response = func(*args, **kwargs)
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/utils/log.py", line 
255, in wrapper
       value = f(*args, **kwargs)
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/views/base_api.py", 
line 108, in wraps
       return f(self, *args, **kwargs)
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/datasets/api.py", line 
937, in import_
       command.run()
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/datasets/commands/importers/dispatcher.py",
 line 68, in run
       raise exc
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/datasets/commands/importers/dispatcher.py",
 line 57, in run
       command.run()
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/commands/importers/v1/__init__.py",
 line 73, in run
       self.validate()
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/commands/importers/v1/__init__.py",
 line 99, in validate
       self._configs = load_configs(
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/commands/importers/v1/utils.py",
 line 186, in load_configs
       schema.load(config)
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/marshmallow/schema.py",
 line 722, in load
       return self._do_load(
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/marshmallow/schema.py",
 line 851, in _do_load
       processed_data = self._invoke_load_processors(
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/marshmallow/schema.py",
 line 1095, in _invoke_load_processors
       data = self._invoke_processors(
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/envs/superset-mods/lib/python3.9/site-packages/marshmallow/schema.py",
 line 1225, in _invoke_processors
       data = processor(data, many=many, **kwargs)
     File 
"/Users/vitoravila/code/superset-mods/superset/superset/datasets/schemas.py", 
line 208, in fix_extra
       data["extra"] = json.loads(data["extra"])
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/lib/python3.9/json/__init__.py", line 
346, in loads
       return _default_decoder.decode(s)
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/lib/python3.9/json/decoder.py", line 
337, in decode
       obj, end = self.raw_decode(s, idx=_w(s, 0).end())
     File 
"/Users/vitoravila/.pyenv/versions/3.9.0/lib/python3.9/json/decoder.py", line 
355, in raw_decode
       raise JSONDecodeError("Expecting value", s, err.value) from None
   json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
   ```
   
   ### Environment
   - browser type and version: Chrome `114.0.5735.198`
   - superset version: `Superset 0.0.0-dev` (master)
   - python version: `3.9.0`
   - node.js version: `v16.14.2`
   
   ### Checklist
   
   - [x] I have checked the superset logs for python stacktraces and included 
it here as text if there are any.
   - [x] I have reproduced the issue with at least the latest released version 
of superset.
   - [x] I have checked the issue tracker for the same issue and I haven't 
found one similar.


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