Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickle compiled without error from AST containing invalid example data #28

Open
elchupanebrej opened this issue Apr 14, 2022 · 3 comments

Comments

@elchupanebrej
Copy link

elchupanebrej commented Apr 14, 2022

πŸ‘“ 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.

@aurelien-reeves
Copy link
Contributor

Thanks for your report πŸ‘

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

@mpkorstanje
Copy link
Contributor

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>.

@elchupanebrej
Copy link
Author

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.

@mpkorstanje mpkorstanje transferred this issue from cucumber/common Nov 8, 2022
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

No branches or pull requests

3 participants