Skip to content

Conversation

@czentgr
Copy link
Contributor

@czentgr czentgr commented Nov 2, 2025

Fixes

  File "/home/runner/work/presto/presto/presto-native-execution/scripts/license-header.py", line 263, in <module>
    sys.exit(main())
             ~~~~^^
  File "/home/runner/work/presto/presto/presto-native-execution/scripts/license-header.py", line 169, in main
    file_pattern = regex.compile(pattern)
  File "/home/runner/.cache/pre-commit/repo54q_3afe/py_env-python3.14/lib/python3.14/site-packages/regex/_main.py", line 353, in compile
    return _compile(pattern, flags, ignore_unused, kwargs, cache_pattern)
  File "/home/runner/.cache/pre-commit/repo54q_3afe/py_env-python3.14/lib/python3.14/site-packages/regex/_main.py", line 542, in _compile
    raise error(caught_exception.msg, caught_exception.pattern,
      caught_exception.pos)
regex._regex_core.error: bad escape \z at position 23

The problem is that \z and \Z are interpreted as python strings before being sent to the re compiler. We indicate that it is not a python string literal by prepending r.

Description

Motivation and Context

Impact

Test Plan

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
  • If adding new dependencies, verified they have an OpenSSF Scorecard score of 5.0 or higher (or obtained explicit TSC approval for lower scores).

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Nov 2, 2025
@sourcery-ai
Copy link
Contributor

sourcery-ai bot commented Nov 2, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

This PR addresses a regex compilation error in the license-header script by updating how the file_pattern is generated and compiled—handling the '\z' escape correctly—and enhances observability with added debug logs.

Class diagram for updated license-header.py script

classDiagram
    class license_header_script {
        +main()
        +get_filename(filename)
        +file_lines(header)
        +message(log_to, msg)
        -file_pattern: regex.Pattern
    }
    license_header_script : +file_pattern generation updated
    license_header_script : +debug logging added
Loading

Flow diagram for updated file pattern generation and matching

flowchart TD
    A["Start main()"] --> B["Read header file lines"]
    B --> C["Generate raw_pattern using fnmatch.translate"]
    C --> D["Replace '\z' with '\Z' in raw_pattern"]
    D --> E["Compile pattern with regex.compile"]
    E --> F["Iterate over files"]
    F --> G["Get filename"]
    G --> H["Log processed filename"]
    H --> I["Match filename against file_pattern"]
    I --> J["Process matched/unmatched files"]
Loading

File-Level Changes

Change Details Files
Refactor file_pattern initialization to fix '\z' escape error
  • Removed the old global file_pattern compilation
  • Built raw_pattern inside main using fnmatch.translate
  • Replaced '\z' escapes with '\Z' before compilation
  • Moved regex.compile call into main after pattern adjustment
presto-native-execution/scripts/license-header.py
Add debug logging around pattern and file processing
  • Logged the final regex pattern before compilation
  • Logged each filename as it is processed
presto-native-execution/scripts/license-header.py

Possibly linked issues

  • #: The PR fixes the bad escape \z regex error in license-header.py that was reported in the issue.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@czentgr czentgr force-pushed the cz_fix_license_check branch from 3a16c71 to 4c02f76 Compare November 2, 2025 18:47
@czentgr czentgr changed the title fix(ci): license check on yml files fix(ci): License check on yml files Nov 2, 2025
@czentgr czentgr force-pushed the cz_fix_license_check branch 8 times, most recently from 004767b to 1c9540e Compare November 3, 2025 20:09
@czentgr czentgr force-pushed the cz_fix_license_check branch from 1c9540e to 780d1e0 Compare November 3, 2025 20:15
@czentgr czentgr marked this pull request as ready for review November 3, 2025 20:16
@czentgr czentgr requested review from a team as code owners November 3, 2025 20:16
@prestodb-ci prestodb-ci requested review from a team, libianoss and xin-zhang2 and removed request for a team November 3, 2025 20:16
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Copy link
Member

@hantangwangd hantangwangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @czentgr

@tdcmeehan tdcmeehan merged commit 7a6c0a3 into prestodb:master Nov 4, 2025
82 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

from:IBM PR from IBM

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The prestocpp-format-and-header-check is consistently failing for the PRs that trigger it

4 participants