Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import dataset fails in case extra value was added and then removed through the UI #24662

Closed
3 tasks done
Vitor-Avila opened this issue Jul 11, 2023 · 2 comments · Fixed by #24663
Closed
3 tasks done

Comments

@Vitor-Avila
Copy link
Contributor

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

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

  • I have checked the superset logs for python stacktraces and included it here as text if there are any.
  • I have reproduced the issue with at least the latest released version of superset.
  • I have checked the issue tracker for the same issue and I haven't found one similar.
Copy link
Member

eschutho commented Jul 11, 2023

Thanks @vitor for this issue!

@ricardolohmann
Copy link

I also had this same problem in versions 2.1.0 and 2.1.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants