René's URL Explorer Experiment


Title: KeyError when using Rule keyword with step data tables or DocStrings · Issue #886 · allure-framework/allure-python · GitHub

Open Graph Title: KeyError when using Rule keyword with step data tables or DocStrings · Issue #886 · allure-framework/allure-python

X Title: KeyError when using Rule keyword with step data tables or DocStrings · Issue #886 · allure-framework/allure-python

Description: Bug Report: Environment OS: Windows Python version: 3.12.10 behave version: 1.3.1 allure-behave version: 2.15.2 allure-commons version: (auto-installed with allure-behave) allure commandline version: 2.35.1 Description When using the Rul...

Open Graph Description: Bug Report: Environment OS: Windows Python version: 3.12.10 behave version: 1.3.1 allure-behave version: 2.15.2 allure-commons version: (auto-installed with allure-behave) allure commandline versio...

X Description: Bug Report: Environment OS: Windows Python version: 3.12.10 behave version: 1.3.1 allure-behave version: 2.15.2 allure-commons version: (auto-installed with allure-behave) allure commandline versio...

Opengraph URL: https://github.com/allure-framework/allure-python/issues/886

X: @github

direct link

Domain: patch-diff.githubusercontent.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"KeyError when using Rule keyword with step data tables or DocStrings","articleBody":"# Bug Report: \n\n## Environment\n- **OS**: Windows\n- **Python version**: 3.12.10\n- **behave version**: 1.3.1\n- **allure-behave version**: 2.15.2\n- **allure-commons version**: (auto-installed with allure-behave)\n- **allure commandline version**: 2.35.1\n\n## Description\nWhen using the `Rule` keyword (introduced in Behave 1.2.6) in feature files, `allure-behave` formatter throws a `KeyError: None` exception when processing steps that contain:\n1. Data tables (tables attached to steps)\n2. DocStrings (multi-line text enclosed in triple quotes `\"\"\"`)\n\n## Expected Behavior\nThe Allure formatter should successfully process scenarios under a `Rule` that contain steps with data tables or DocStrings, just as it does for scenarios without the `Rule` keyword.\n\n## Actual Behavior\nThe formatter crashes with a `KeyError: None` traceback when attempting to attach step data (tables or text) to the Allure report.\n\n## Steps to Reproduce\n\n### 1. Create a feature file with Rule and data table\n**File: `test/features/simple/tutorial.feature`**\n```gherkin\nFeature: showing off behave\n\n\tRule: Basic arithmetic operations\n\n\t\tScenario: Passing a table as a data through step\n\t\t\tGiven we have behave installed\n\t\t\tWhen we pass a table as a data through step\n\t\t\t\t| number1 | number2 | result |\n\t\t\t\t| 2       | 3       | 5      |\n\t\t\t\t| 4       | 5       | 9      |\n\t\t\tThen behave should be able to read the table\n```\n\n### 2. Create step definitions\n**File: `test/steps/steps_tutorial.py`**\n```python\nfrom behave import given, when, then\n\n@given('we have behave installed')\ndef step_impl(context):\n    pass\n\n@when('we pass a table as a data through step')\ndef step_impl(context):\n    assert context.table\n\n@then('behave should be able to read the table')\ndef step_impl(context):\n    pass\n```\n\n### 3. Run with Allure formatter\n```bash\nbehave -f allure_behave.formatter:AllureFormatter -o allure_result_folder\n```\n\n### 4. Observe the error\n```\nException KeyError: None\nTraceback (most recent call last):\n  ...\n  File \"allure_behave/listener.py\", line 147, in start_behave_step\n    self.logger.attach_data(uuid4(), step_table(step), name='.table', attachment_type=AttachmentType.CSV)\n  File \"allure_commons/reporter.py\", line 163, in attach_data\n    file_name = self._attach(uuid, name=name, attachment_type=attachment_type,\n  File \"allure_commons/reporter.py\", line 153, in _attach\n    self._items[last_uuid].attachments.append(attachment)\n  File \"allure_commons/reporter.py\", line 33, in __getitem__\n    return self.thread_context.__getitem__(item)\nKeyError: None\n```\n\n## Additional Testing\n\n### Works ✅\n- Simple scenarios under `Rule` (no tables/DocStrings)\n- Scenario Outlines with Examples tables under `Rule`\n- All scenario types WITHOUT `Rule` keyword\n\n### Fails ❌\n- Steps with data tables under `Rule`\n- Steps with DocStrings under `Rule`\n\n### Test Results Matrix\n\n| Scenario Type | Without Rule | With Rule |\n|--------------|--------------|-----------|\n| Simple scenario | ✅ Works | ✅ Works |\n| Scenario Outline with Examples | ✅ Works | ✅ Works |\n| Step with data table | ✅ Works | ❌ **Fails** |\n| Step with DocString | ✅ Works | ❌ **Fails** |\n\n## Root Cause Analysis\nThe issue appears to be in `allure_behave/listener.py` at line 147 (data tables) and line 144 (DocStrings). When processing scenarios under a `Rule`, the `last_uuid` is `None`, causing the attachment operation to fail when trying to access `self._items[last_uuid]`.\n\nThe `Rule` hierarchy creates a different context structure that the formatter doesn't handle correctly when attaching step data.\n\n## Suggested Fix\nThe `start_behave_step` method in `allure_behave/listener.py` needs to properly handle the context hierarchy when scenarios are nested under a `Rule`. The `last_uuid` should be correctly resolved even when scenarios are children of a `Rule` element.\n\n## Additional Context\n- The `Rule` keyword is a valid Gherkin construct for organizing scenarios\n- Behave 1.2.6+ fully supports the `Rule` keyword\n- This issue prevents using Allure reporting with modern Gherkin best practices\n\n## References\n- Gherkin Rule keyword documentation: https://cucumber.io/docs/gherkin/reference/#rule\n- Behave changelog (Rule support): https://github.com/behave/behave/blob/main/CHANGES.rst\n\n","author":{"url":"https://github.com/hemz10","@type":"Person","name":"hemz10"},"datePublished":"2025-12-01T07:58:28.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/886/allure-python/issues/886"}

route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:69ed2ca6-9cbb-78de-6b28-d39ad290f141
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idA774:B1641:546214:71E27E:696E77C1
html-safe-nonce5858d3b5fc045a09e4e25d55b35084883bb7813134fbfc7af7003743bb7e8dfc
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzc0OkIxNjQxOjU0NjIxNDo3MUUyN0U6Njk2RTc3QzEiLCJ2aXNpdG9yX2lkIjoiMTA3MzAzMzg4NjMwOTQ0NzYxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmace39d7d7aab68a08ddd9a83ed9300d89b25e8b6d6a787ba7ac75165dfa5cf5ec0
hovercard-subject-tagissue:3679749409
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/allure-framework/allure-python/886/issue_layout
twitter:imagehttps://opengraph.githubassets.com/228ef633781d3187d11ffabc092d665fe0a0e5ddcc0997995cfb1d341e7bb795/allure-framework/allure-python/issues/886
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/228ef633781d3187d11ffabc092d665fe0a0e5ddcc0997995cfb1d341e7bb795/allure-framework/allure-python/issues/886
og:image:altBug Report: Environment OS: Windows Python version: 3.12.10 behave version: 1.3.1 allure-behave version: 2.15.2 allure-commons version: (auto-installed with allure-behave) allure commandline versio...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamehemz10
hostnamegithub.com
expected-hostnamegithub.com
None01185010a96388a2a8cd8bd7f5824fdf090522b219f9aecf8c7ff1857aeb489b
turbo-cache-controlno-preview
go-importgithub.com/allure-framework/allure-python git https://github.com/allure-framework/allure-python.git
octolytics-dimension-user_id5879127
octolytics-dimension-user_loginallure-framework
octolytics-dimension-repository_id79346720
octolytics-dimension-repository_nwoallure-framework/allure-python
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id79346720
octolytics-dimension-repository_network_root_nwoallure-framework/allure-python
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release673a80c1bce2a1e6a48b530ce2b72bf8fd253386
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/886#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fallure-framework%2Fallure-python%2Fissues%2F886
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fallure-framework%2Fallure-python%2Fissues%2F886
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=allure-framework%2Fallure-python
Reloadhttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/886
Reloadhttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/886
Reloadhttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/886
allure-framework https://patch-diff.githubusercontent.com/allure-framework
allure-pythonhttps://patch-diff.githubusercontent.com/allure-framework/allure-python
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fallure-framework%2Fallure-python
Fork 256 https://patch-diff.githubusercontent.com/login?return_to=%2Fallure-framework%2Fallure-python
Star 789 https://patch-diff.githubusercontent.com/login?return_to=%2Fallure-framework%2Fallure-python
Code https://patch-diff.githubusercontent.com/allure-framework/allure-python
Issues 95 https://patch-diff.githubusercontent.com/allure-framework/allure-python/issues
Pull requests 20 https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulls
Actions https://patch-diff.githubusercontent.com/allure-framework/allure-python/actions
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/allure-framework/allure-python/security
Please reload this pagehttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/886
Insights https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulse
Code https://patch-diff.githubusercontent.com/allure-framework/allure-python
Issues https://patch-diff.githubusercontent.com/allure-framework/allure-python/issues
Pull requests https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulls
Actions https://patch-diff.githubusercontent.com/allure-framework/allure-python/actions
Security https://patch-diff.githubusercontent.com/allure-framework/allure-python/security
Insights https://patch-diff.githubusercontent.com/allure-framework/allure-python/pulse
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/allure-framework/allure-python/issues/886
New issuehttps://patch-diff.githubusercontent.com/login?return_to=https://github.com/allure-framework/allure-python/issues/886
KeyError when using Rule keyword with step data tables or DocStringshttps://patch-diff.githubusercontent.com/allure-framework/allure-python/issues/886#top
https://github.com/hemz10
https://github.com/hemz10
hemz10https://github.com/hemz10
on Dec 1, 2025https://github.com/allure-framework/allure-python/issues/886#issue-3679749409
https://cucumber.io/docs/gherkin/reference/#rulehttps://cucumber.io/docs/gherkin/reference/#rule
https://github.com/behave/behave/blob/main/CHANGES.rsthttps://github.com/behave/behave/blob/main/CHANGES.rst
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.