Skip to content

Modification for how nac-validate handles python 3.14 warning messages.#370

Merged
danischm merged 1 commit intonetascode:mainfrom
alaramir0:python3_14_support
Mar 18, 2026
Merged

Modification for how nac-validate handles python 3.14 warning messages.#370
danischm merged 1 commit intonetascode:mainfrom
alaramir0:python3_14_support

Conversation

@alaramir0
Copy link
Contributor

@alaramir0 alaramir0 commented Mar 11, 2026

The need to modify this originates because when users install python 3.14 or later and then try to run nac-validate tool they will see a bunch of warning messages even though they are not breaking anything in their schema or yaml files.

They will see something like this.
nac-validate --version
nac-validate, version 1.2.0

nac-validate -s schemas/schema.yaml -r validation/rules/ data/ .defaults/ -v DEBUG
INFO - Loading schema
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "." is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\."? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
:1: SyntaxWarning: "[" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\["? A raw string is also an option.
:1: SyntaxWarning: "." is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\."? A raw string is also an option.
:1: SyntaxWarning: "-" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\-"? A raw string is also an option.
:1: SyntaxWarning: "-" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\-"? A raw string is also an option.
:1: SyntaxWarning: "[" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\["? A raw string is also an option.
:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.
… snip…
:1: SyntaxWarning: "[" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\["? A raw string is also an option.
INFO - Loading rules

The nac-validate tool includes a script called validator.py that already has a function that catches the warnings and ignores them. The reason why these warnings are caught with releases below 3.14 but not caught when using python 3.14 is because the warning message generated doesn't match what the function is expecting as a pattern.

Current script inside nac-validate is expecting the message to begin with:

message="invalid escape sequence"

As shown above, the warnings similarly begin with:

:1: SyntaxWarning: "\d" is an invalid escape sequence. Such sequences will not work in the future. Did you mean "\d"? A raw string is also an option.

After doing some testing I modified the pattern that the script is expecting to:

message=r".invalid escape sequence."

that way it matches that pattern anywhere in the message. After modifying that line please see on the image how execution went. I tested it with one validation rule error on purpose just to see if nac-validate it's working fine.

Screenshot 2026-03-10 at 5 08 36 p m

That would help people avoid those warning messages when using python 3.14 while executing nac-validate and continue to work normally.

@tzarski0 tzarski0 requested a review from danischm March 12, 2026 08:15
@danischm danischm merged commit 7c45e86 into netascode:main Mar 18, 2026
7 checks passed
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 this pull request may close these issues.

3 participants