Skip to content

OSV scanner failing with "SyntaxWarning: "\s" is an invalid escape sequence" #1162

Description

@debkanchan

OSV scanner fails with following error:

stderr: |
        /Users/dk/.cache/trunk/plugins/https---github-com-trunk-io-plugins/v1.10.1-4ebadccd80b22638/linters/osv-scanner/osv_to_sarif.py:139: SyntaxWarning: "\s" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\s"? A raw string is also an option.
          f'(^|\s)({pkg["name"]})($|\s)',
        /Users/dk/.cache/trunk/plugins/https---github-com-trunk-io-plugins/v1.10.1-4ebadccd80b22638/linters/osv-scanner/osv_to_sarif.py:139: SyntaxWarning: "\s" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\\s"? A raw string is also an option.
          f'(^|\s)({pkg["name"]})($|\s)',
        Traceback (most recent call last):
          File "/Users/dk/.cache/trunk/plugins/https---github-com-trunk-io-plugins/v1.10.1-4ebadccd80b22638/linters/osv-scanner/osv_to_sarif.py", line 203, in <module>
            main(sys.argv)
            ~~~~^^^^^^^^^^
          File "/Users/dk/.cache/trunk/plugins/https---github-com-trunk-io-plugins/v1.10.1-4ebadccd80b22638/linters/osv-scanner/osv_to_sarif.py", line 149, in main
            if pkg["name"].lower() != affected_pkg["package"]["name"].lower():
                                      ~~~~~~~~~~~~^^^^^^^^^^^
        KeyError: 'package'

looking at the line the error makes sense because how escaping works in Python 3.12+

f'(^|\s)({pkg["name"]})($|\s)',

System info:
MacOS: 26.5.2 (25F84)
trunk version: 1.25.0
runtime: python@3.14.4
plugins version: v1.10.1
osv-scanner@2.2.4

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions