common icon indicating copy to clipboard operation
common copied to clipboard

Pickle compiled without error from AST containing invalid example data

Open elchupanebrej opened this issue 3 years ago • 3 comments

👓 What did you see? - Pickle compiled without error from AST containing invalid example data

✅ What did you expect to see? - Pickle compilation fails on invalid incoming data from AST

📦 Which tool/library version are you using? - https://pypi.org/project/gherkin-official/23.0.1/

🔬 How could we reproduce it?

from gherkin.parser import Parser
from gherkin.pickles.compiler import Compiler

feature = """\
Feature: Outline
    Scenario Outline: Outlined with duplicated parameter example table
         Given there are <start> cucumbers
         When I eat <eat> cucumbers
         Then I should have <left> cucumbers

          Examples:
            | start | start | left |
            |   12  |   10  |   7  |
            |    2  |    1  |   1  |
"""

gherkin_ast_data = Parser().parse(feature)
gherkin_ast_data["uri"]='uri'
try:
    pickles_data = Compiler().compile(gherkin_ast_data)
except Exception:
    pass
else:
    raise RuntimeError('Pickles were loaded and are broken')

📚 Any additional context?


This text was originally generated from a template, then edited by hand. You can modify the template here.

elchupanebrej avatar Apr 14 '22 13:04 elchupanebrej

Thanks for your report 👍

At first I'll check if this is reproducible outside python

aurelien-reeves avatar Apr 15 '22 07:04 aurelien-reeves

Note: This ticket highlights two issues at once. I would strongly suggest treating these separately or the fix for the first will get bogged down in the discussion of the second.

  1. Duplicated columns.

The duplicated start columns are unambiguously wrong and should result in error.

  1. A substitution pattern <eat> that is not replaced.

Because of the way Gherkin has been defined I don't see any way of fixing this. We can not tell the difference between a substitution pattern or accidental Gherkin. For example:

Then the "temperature<6" and "humidity>12" is displayed

Contains the substitution <6" and "humidity>.

mpkorstanje avatar Apr 15 '22 08:04 mpkorstanje

This ticket is addressed to:

  1. Duplicated columns.

The duplicated start columns are unambiguously wrong and should result in error.

The second (smaller) issue will produce an error on pickle execution and is not the target of this ticket

  1. A substitution pattern <eat> that is not replaced.

elchupanebrej avatar Apr 15 '22 09:04 elchupanebrej