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

ValueError: malformed node or string when attempting to rebase-migration #52

Closed
jpsingleton opened this issue Mar 8, 2021 · 2 comments · Fixed by #54
Closed

ValueError: malformed node or string when attempting to rebase-migration #52

jpsingleton opened this issue Mar 8, 2021 · 2 comments · Fixed by #54

Comments

@jpsingleton
Copy link

When attempting python manage.py rebase-migration <app_label> during rebase conflict resolution:

Traceback (most recent call last):
  File "manage.py", line 58, in <module>
    run_django()
  File "manage.py", line 54, in run_django
    execute_from_command_line(argv)
  File "venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "venv/lib/python3.8/site-packages/django/core/management/__init__.py", line 395, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "venv/lib/python3.8/site-packages/django/core/management/base.py", line 328, in run_from_argv
    self.execute(*args, **cmd_options)
  File "venv/lib/python3.8/site-packages/django/core/management/base.py", line 369, in execute
    output = self.handle(*args, **options)
  File "venv/lib/python3.8/site-packages/django_linear_migrations/management/commands/rebase-migration.py", line 95, in handle
    dependencies = ast.literal_eval(deps)
  File ".pyenv/versions/3.8.8/lib/python3.8/ast.py", line 99, in literal_eval
    return _convert(node_or_string)
  File ".pyenv/versions/3.8.8/lib/python3.8/ast.py", line 82, in _convert
    return list(map(_convert, node.elts))
  File ".pyenv/versions/3.8.8/lib/python3.8/ast.py", line 98, in _convert
    return _convert_signed_num(node)
  File ".pyenv/versions/3.8.8/lib/python3.8/ast.py", line 75, in _convert_signed_num
    return _convert_num(node)
  File ".pyenv/versions/3.8.8/lib/python3.8/ast.py", line 66, in _convert_num
    _raise_malformed_node(node)
  File ".pyenv/versions/3.8.8/lib/python3.8/ast.py", line 63, in _raise_malformed_node
    raise ValueError(f'malformed node or string: {node!r}')
ValueError: malformed node or string: <_ast.Call object at 0x7fe9727b9850>
@adamchainz
Copy link
Owner

Would need to see the contents of the migration file to see the bug here - can you send that to me privately?

@adamchainz
Copy link
Owner

This issue was caused by a swappable dependency on the user model setting:

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("example", ".."),
    ]

I guess we really need to use a full ast parse, rather than assuming it will work as a literal.

adamchainz added a commit that referenced this issue Mar 9, 2021
* Fix rebase-migration to handle swappable dependencies

Fixes #52.
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.

2 participants