Misleading error when unescaped empty brackets

Create issue
Issue #1087 new
Former user created an issue

Hi there,

Some shell commands like find [...] -exec often use {} which must be escaped when used in snakemake. However, when you forget to use {{}}, snakemake only complains about an IndexError in the rule.

Error in rule XX
IndexError: list index out of range

This is misleading and it took me a lot of time to track down that the use of {} was at fault. I have noticed that where the error initially occurs, snakemake already catches KeyError and provide a warning about escaping brackets (L374 in utils.py):

    try:
        return fmt.format(_pattern, *args, **variables)
    except KeyError as ex:
        raise NameError("The name {} is unknown in this context. Please "
                        "make sure that you defined that variable. "
                        "Also note that braces not used for variable access "
                        "have to be escaped by repeating them, "
                        "i.e. {{{{print $1}}}}".format(str(ex)))

Would it be possible to display the same kind of warning for IndexErrors provoked by the use of {} ?

Cheers, Nils

Comments (0)

  1. Log in to comment