EBoisseauSierra opened a new issue #19103:
URL: https://github.com/apache/superset/issues/19103


   `superset import-dashboards` fails when a dataset has its “Extra” details 
specified… but empty (i.e. `{}`).
   
   #### How to reproduce the bug
   
   1. Specify the Extra field:
     1. Go to Data/Datasets menu,
     1. Click on Edit dataset,
     1. Click on Use legacy Editor,
     1. In Edit Table/Detail tab, scroll to the last row and specify Extra as 
`{}`. 
   2. Export instance: `superset export-dashboards --file my_archive.zip`
   3. Change instance (should you want to)
   3. Import instance: `superset import-dashboards --path my_archive.zip`
   
   ### Expected results
   
   JustWorks™
   
   ### Actual results
   
   ```
   $ superset import-dashboards --path my_archive.zip
   …
   Command failed validation
   2022-03-09 
14:32:11,353:INFO:superset.dashboards.commands.importers.dispatcher:Command 
failed validation
   There was an error when importing the dashboards(s), please check the 
exception traceback in the log
   Traceback (most recent call last):
     File "/opt/superset/venv/lib/python3.7/site-packages/superset/cli.py", 
line 360, in import_dashboards
       ImportDashboardsCommand(contents, overwrite=True).run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 64, in run
       raise exc
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 57, in run
       command.run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 63, in run
       self.validate()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 161, in validate
       raise exception
   superset.commands.exceptions.CommandInvalidError: Error importing dashboard
   Segmentation fault
   ```
   
   ### Environment
   
   - superset version: `1.4.1`
   - python version: `3.7`
   - any feature flags active: `"VERSIONED_EXPORT": True`.
   
   ### Checklist
   
   Make sure to follow these steps before submitting your issue - thank you!
   
   - [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.
   
   ### Additional context
   
   I've tracked down the Exception be first thrown by the Marshmallow (version 
`3.14.1` — current latest) definition, and more precisely [this 
module](https://github.com/marshmallow-code/marshmallow/blob/3.14.1/src/marshmallow/fields.py).
   
   The Exception I get from Superset looks like:
   
   ```
   [ValidationError({'columns': {0: {'extra': ['Not a valid mapping type.']}, 
1: {'extra': ['Not a valid mapping type.']}})]
   ```
   (where `0`, and `1` are the rank of the columns I have implemented the empty 
Extra field in).
   
   The `Not a valid mapping type` is [this 
one](https://github.com/marshmallow-code/marshmallow/blob/3.14.1/src/marshmallow/fields.py#L1510).
   
   I can see that, back on Superset's side, the 
[`ImportModelsCommand.contents.items()](https://github.com/apache/superset/blob/1.4.1rc2/superset/commands/importers/v1/__init__.py#L101)
 to be validated contains the following (beautified manually):
   
   ```
   dict_items([…,
       (
           'datasets/my_db/my_table.yaml',
           '
           cache_timeout: null
           columns:
           - {column_name: timestamp, description: null, expression: null, 
extra: \'{}\', filterable: true,
     groupby: true, is_active: true, is_dttm: true, python_date_format: null, 
type: TIMESTAMP
       WITH TIME ZONE, verbose_name: null}
         …
   ```
   
   What is interesting is the `extra: \'{}\',` part, that is likely causing the 
issue, and raises [this 
exception](https://github.com/marshmallow-code/marshmallow/blob/3.14.1/src/marshmallow/fields.py#L1585)
 that then “bubbles up”.
   
   ---
   
   As an interesting bonus, the Python stack traces not always ends up with 
   
   ```
   …
   superset.commands.exceptions.CommandInvalidError: Error importing dashboard
   Segmentation fault
   ```
   
   as mentioned above. I have also faced:
   
   ```
   2022-03-10 
15:56:55,214:INFO:superset.dashboards.commands.importers.dispatcher:Command 
failed validation
   There was an error when importing the dashboards(s), please check the 
exception traceback in the log
   Traceback (most recent call last):
     File "/opt/superset/venv/lib/python3.7/site-packages/superset/cli.py", 
line 360, in import_dashboards
       ImportDashboardsCommand(contents, overwrite=True).run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 64, in run
       raise exc
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 57, in run
       command.run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 63, in run
       self.validate()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 161, in validate
       raise exception
   superset.commands.exceptions.CommandInvalidError: Error importing dashboard
   Traceback (most recent call last):
     File "/opt/superset/venv/lib/python3.7/site-packages/superset/cli.py", 
line 360, in import_dashboards
       ImportDashboardsCommand(contents, overwrite=True).run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 64, in run
       raise exc
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 57, in run
       command.run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 63, in run
       self.validate()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 161, in validate
       raise exception
   superset.commands.exceptions.CommandInvalidError: Error importing dashboard
   
   During handling of the above exception, another exception occurred:
   
   Traceback (most recent call last):
     File "/opt/superset/venv/bin/superset", line 33, in <module>
       sys.exit(load_entry_point('apache-superset==1.4.1', 'console_scripts', 
'superset')())
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
829, in __call__
       return self.main(*args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/flask/cli.py", line 
586, in main
       return super(FlaskGroup, self).main(*args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
782, in main
       rv = self.invoke(ctx)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
1259, in invoke
       return _process_result(sub_ctx.command.invoke(sub_ctx))
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
1066, in invoke
       return ctx.invoke(self.callback, **ctx.params)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
610, in invoke
       return callback(*args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/decorators.py", 
line 21, in new_func
       return f(get_current_context(), *args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/flask/cli.py", line 
426, in decorator
       return __ctx.invoke(f, *args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
610, in invoke
       return callback(*args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/decorators.py", 
line 21, in new_func
       return f(get_current_context(), *args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/flask/cli.py", line 
426, in decorator
       return __ctx.invoke(f, *args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/click/core.py", line 
610, in invoke
       return callback(*args, **kwargs)
     File "/opt/superset/venv/lib/python3.7/site-packages/superset/cli.py", 
line 363, in import_dashboards
       "There was an error when importing the dashboards(s), please check "
     File "/usr/lib/python3.7/logging/__init__.py", line 1418, in exception
       self.error(msg, *args, exc_info=exc_info, **kwargs)
     File "/usr/lib/python3.7/logging/__init__.py", line 1412, in error
       self._log(ERROR, msg, args, **kwargs)
     File "/usr/lib/python3.7/logging/__init__.py", line 1519, in _log
       self.handle(record)
     File "/usr/lib/python3.7/logging/__init__.py", line 1529, in handle
       self.callHandlers(record)
     File "/usr/lib/python3.7/logging/__init__.py", line 1591, in callHandlers
       hdlr.handle(record)
     File "/usr/lib/python3.7/logging/__init__.py", line 905, in handle
       self.emit(record)
     File "/opt/superset/venv/lib/python3.7/site-packages/systemd/journal.py", 
line 157, in emit
       send(**data)
     File "systemd/_journal.pyx", line 68, in systemd._journal.send
     File "systemd/_journal.pyx", line 48, in systemd._journal._send
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/exceptions.py",
 line 31, in __repr__
       return repr(self)
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/exceptions.py",
 line 31, in __repr__
       return repr(self)
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/exceptions.py",
 line 31, in __repr__
       return repr(self)
     [Previous line repeated 320 more times]
   RecursionError: maximum recursion depth exceeded while getting the repr of 
an object
   ```
   
   and
   
   ```
   Command failed validation
   2022-03-10 
15:44:46,566:INFO:superset.dashboards.commands.importers.dispatcher:Command 
failed validation
   There was an error when importing the dashboards(s), please check the 
exception traceback in the log
   Traceback (most recent call last):
     File "/opt/superset/venv/lib/python3.7/site-packages/superset/cli.py", 
line 360, in import_dashboards
       ImportDashboardsCommand(contents, overwrite=True).run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 64, in run
       raise exc
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/dashboards/commands/importers/dispatcher.py",
 line 57, in run
       command.run()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 63, in run
       self.validate()
     File 
"/opt/superset/venv/lib/python3.7/site-packages/superset/commands/importers/v1/__init__.py",
 line 161, in validate
       raise exception
   superset.commands.exceptions.CommandInvalidError: Error importing dashboard
   double free or corruption (out)
   Aborted
   ```


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