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

MarkupSafe update breaks Jinja #1591

Closed
MichaelVoelkel opened this issue Feb 18, 2022 · 1 comment
Closed

MarkupSafe update breaks Jinja #1591

MichaelVoelkel opened this issue Feb 18, 2022 · 1 comment

Comments

@MichaelVoelkel
Copy link

Hi,

MarkupSafe is automatically put to the latest version via pip but this apparently breaks Lintly.

Traceback (most recent call last):
[9](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:9)
  File "/usr/local/bin/lintly", line 5, in <module>
[10](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:10)
    from lintly.cli import main
[11](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:11)
  File "/usr/local/lib/python3.9/site-packages/lintly/cli.py", line 7, in <module>
[12](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:12)
    from .builds import LintlyBuild
[13](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:13)
  File "/usr/local/lib/python3.9/site-packages/lintly/builds.py", line [14](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:14), in <module>
14
    from .backends.github import GitHubBackend
[15](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:15)
  File "/usr/local/lib/python3.9/site-packages/lintly/backends/__init__.py", line 1, in <module>
[16](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:16)
    from .github import GitHubBackend  # noqa
[17](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:17)
  File "/usr/local/lib/python3.9/site-packages/lintly/backends/github.py", line 11, in <module>
[18](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:18)
    from lintly.formatters import (
[19](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:19)
  File "/usr/local/lib/python3.9/site-packages/lintly/formatters.py", line 6, in <module>
[20](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:20)
    from jinja2 import Environment, FileSystemLoader
[21](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:21)
  File "/usr/local/lib/python3.9/site-packages/jinja2/__init__.py", line 12, in <module>
[22](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:22)
    from .environment import Environment
[23](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:23)
  File "/usr/local/lib/python3.9/site-packages/jinja2/environment.py", line 25, in <module>
[24](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:24)
    from .defaults import BLOCK_END_STRING
[25](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:25)
  File "/usr/local/lib/python3.9/site-packages/jinja2/defaults.py", line 3, in <module>
[26](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:26)
    from .filters import FILTERS as DEFAULT_FILTERS  # noqa: F401
[27](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:27)
  File "/usr/local/lib/python3.9/site-packages/jinja2/filters.py", line 13, in <module>
[28](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:28)
    from markupsafe import soft_unicode
[29](https://github.com/fw-dev/FileWave/runs/5245874635?check_suite_focus=true#step:4:29)
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.9/site-packages/markupsafe/__init__.py)

So, require should probably go to >=2.0 and <2.1? Or just not use soft_unicode?

@davidism
Copy link
Member

davidism commented Feb 18, 2022

Duplicate of #1585

You are using an unsupported version of the project, please update to the latest version. Additionally, please read https://hynek.me/articles/semver-will-not-save-you/, then use a tool like pip-tools to pin your dependencies and control when you get updates. Be sure to run your tests with deprecation warnings treated as errors so that you get notified of these types of changes early.

qiluo-msft pushed a commit to sonic-net/sonic-buildimage that referenced this issue Feb 21, 2022
#### Why I did it

1. Fix Build exception [example](https://dev.azure.com/mssonic/build/_build/results?buildId=73911&view=logs&jobId=88ce9a53-729c-5fa9-7b6e-3d98f2488e3f&j=cef3d8a9-152e-5193-620b-567dc18af272&t=ac3bce9f-b126-5a26-3fee-28ce0ec1679d)

```
2022-02-19T01:54:23.4200556Z ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/usr/local/lib/python3.8/dist-packages/markupsafe/__init__.py)
```

This is because Jinja2 uses MarkupSafe without specifying an upper limit to the version, MarkupSafe version that was released today removed 'soft_unicode'. So now Jinja2 is complaining.

Related issues:
pallets/jinja#1591
aws/aws-sam-cli#3661


2. Reverts #9136

Fixing build failures in SONiC utils [example](https://dev.azure.com/mssonic/build/_build/results?buildId=73784&view=logs&jobId=83516c17-6666-5250-abde-63983ce72a49&j=83516c17-6666-5250-abde-63983ce72a49&t=6177235f-d4f1-5f72-835a-90ebb93a1784)

One of the errors:
```
 TestPathAddressing.test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths 

self = <tests.generic_config_updater.gu_common_test.TestPathAddressing testMethod=test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths>

    def test_find_ref_paths__ref_is_the_whole_key__returns_ref_paths(self):
        # Arrange
        path = "/PORT/Ethernet0"
        expected = [
            "/ACL_TABLE/NO-NSW-PACL-V4/ports/0",
            "/VLAN_MEMBER/Vlan1000|Ethernet0",
        ]
    
        # Act
        actual = self.path_addressing.find_ref_paths(path, Files.CROPPED_CONFIG_DB_AS_JSON)
    
        # Assert
>       self.assertEqual(expected, actual)
E       AssertionError: Lists differ: ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0', '/VLAN_MEMBER/Vlan1000|Ethernet0'] != ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0']
E       
E       First list contains 1 additional elements.
E       First extra element 1:
E       '/VLAN_MEMBER/Vlan1000|Ethernet0'
E       
E       - ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0', '/VLAN_MEMBER/Vlan1000|Ethernet0']
E       + ['/ACL_TABLE/NO-NSW-PACL-V4/ports/0']
```

The VLAN_MEMBER backlink (can be called referrer link or ref link) is not found.

Issue introduced by #9136
I don't know how this PR passed the build system, it should have failed.

Known YANG issue #9312

#### How I did it
The import to `sonic-vlan` is breaking the build
```
    import sonic-vlan {
        prefix vlan;
    }
```

I am not sure if that's the only issue, so I think reverting the whole PR should be the safer option.

#### How to verify it
Ran sonic-utils tests locally.
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants