Commit fa57355
feat: Issue a warning when unsupported characters are used in wildcard names (#1587)
### Description
Currently, wildcard names can only include alphanumeric characters and
underscores. When an unsupported character such as `-` is used in a
wildcard name, it is silently ignored. Making matters worse, the entire
wildcard name is truncated, leading to confusing error messages like
seen in #1349.
This PR should close #1349 and #1579
#### Solution
When registering wildcard names, attempt is first made to match "legal"
regex pattern for a whilcard name. When that matching fails and returns
`None`, it's either because there isn't a wildcard in the file name, or
an "illegal" name is used for the wildcard. We then match again to a
relaxed regex pattern, where we specifically look for any non-word
characters (`\W`) before any commas in wildcard definition. If this
returns a match, we issue a warning informing users of illegal names.
#### Alternative
Alternatively, an error can be raised in lieu of a warning. I opted not
to do this because I'm not sure if there could be any legitimate case
where `{}` are used but not for wildcard difinition (`{{}}` escaped
brackets are already accounted for in relaxed regex matching) and
therefore I'm not comfortable raising an exception at this stage. But if
not, then we should probably raise a `WildcardError` instead. I see that
`WildcardError` is currently not implemented. Do we have a plan for this
exception class yet?
### QC
<!-- Make sure that you can tick the boxes below. -->
* [ ] The PR contains a test case for the changes or the changes are
already covered by an existing test case.
* [ ] The documentation (`docs/`) is updated to reflect the changes or
this is not necessary (e.g. if the change does neither modify the
language nor the behavior or functionalities of Snakemake).
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit
* **New Features**
* Added warnings when file patterns contain illegal wildcard names.
* **Bug Fixes**
* Validation now runs earlier to catch wildcard/name issues sooner.
* Ensures outputs, logs, and benchmarks use a consistent wildcard set
with clearer errors.
* **Refactor**
* Public wildcard-registration API updated; integrations or extensions
relying on previous behavior may need small adjustments.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
---------
Co-authored-by: Johannes Köster <johannes.koester@tu-dortmund.de>
Co-authored-by: Johannes Koester <johannes.koester@uni-due.de>1 parent 06ba7e6 commit fa57355
2 files changed
Lines changed: 28 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
487 | 487 | | |
488 | 488 | | |
489 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
490 | 495 | | |
491 | 496 | | |
492 | 497 | | |
| |||
991 | 996 | | |
992 | 997 | | |
993 | 998 | | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
994 | 1010 | | |
995 | 1011 | | |
996 | 1012 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
246 | 246 | | |
247 | 247 | | |
248 | 248 | | |
249 | | - | |
| 249 | + | |
| 250 | + | |
250 | 251 | | |
251 | 252 | | |
252 | 253 | | |
| |||
318 | 319 | | |
319 | 320 | | |
320 | 321 | | |
321 | | - | |
| 322 | + | |
| 323 | + | |
322 | 324 | | |
323 | 325 | | |
324 | 326 | | |
| |||
363 | 365 | | |
364 | 366 | | |
365 | 367 | | |
366 | | - | |
| 368 | + | |
367 | 369 | | |
368 | 370 | | |
369 | 371 | | |
| |||
531 | 533 | | |
532 | 534 | | |
533 | 535 | | |
| 536 | + | |
534 | 537 | | |
535 | 538 | | |
536 | 539 | | |
| |||
614 | 617 | | |
615 | 618 | | |
616 | 619 | | |
617 | | - | |
| 620 | + | |
618 | 621 | | |
619 | 622 | | |
620 | 623 | | |
| |||
625 | 628 | | |
626 | 629 | | |
627 | 630 | | |
628 | | - | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
| 635 | + | |
629 | 636 | | |
630 | 637 | | |
631 | 638 | | |
| |||
0 commit comments