Skip to content

Reject non-table scenario sections#4769

Merged
FlorianPfaff merged 2 commits into
mainfrom
agent/reject-nontable-scenario-sections
Jul 26, 2026
Merged

Reject non-table scenario sections#4769
FlorianPfaff merged 2 commits into
mainfrom
agent/reject-nontable-scenario-sections

Conversation

@FlorianPfaff

Copy link
Copy Markdown
Owner

Bug

A syntactically valid TOML file can define scenario as a scalar or array instead of a table, for example:

scenario = "linear_gaussian"

The scenario dispatcher and both direct scenario runners immediately called .get(...) on that value. This leaked an internal AttributeError instead of rejecting the malformed configuration through the public validation path.

Fix

  • add one shared _scenario_section() validator;
  • reject non-table scenario values with ValueError("scenario must be a TOML table");
  • reuse the validated table for type and name lookup in both built-in runners;
  • preserve the existing behavior for absent, empty, and unsupported scenario types.

Regression coverage

The new test exercises all three public entry points against string-, integer-, and array-valued scenario entries (nine cases total).

Validation

  • updated module and regression test pass python -m py_compile;
  • focused standalone reproduction passed for all nine cases;
  • branch is 2 commits ahead of main and 0 behind;
  • diff is limited to src/pyrecest/scenarios.py and tests/test_scenario_section_validation.py.

Repository CI should run the full backend and test matrices on this pull request.

@github-actions

Copy link
Copy Markdown
Contributor

MegaLinter analysis: Success

Descriptor Linter Files Fixed Errors Warnings Elapsed time
✅ COPYPASTE jscpd yes no no 23.61s
✅ JSON prettier 7 0 0 0 1.05s
✅ JSON v8r 7 0 0 4.71s
✅ MARKDOWN markdownlint 68 0 0 0 1.76s
✅ MARKDOWN markdown-table-formatter 68 0 0 0 0.9s
✅ PYTHON black 1703 257 0 0 98.29s
✅ PYTHON isort 1703 482 0 0 2.77s
✅ REPOSITORY betterleaks yes no no 1.92s
✅ REPOSITORY checkov yes no no 57.06s
✅ REPOSITORY gitleaks yes no no 16.23s
✅ REPOSITORY git_diff yes no no 0.32s
✅ REPOSITORY secretlint yes no no 77.52s
✅ REPOSITORY syft yes no no 5.2s
✅ REPOSITORY trivy-sbom yes no no 6.23s
✅ REPOSITORY trufflehog yes no no 33.04s
✅ YAML prettier 11 0 0 0 0.67s
✅ YAML v8r 11 0 0 11.62s
✅ YAML yamllint 11 0 0 0.49s

Notices

📣 MegaLinter 9.5.0 is out! Discover the new features and security recommendations in the release announcement. (Skip this info by defining SECURITY_SUGGESTIONS: false)

See detailed reports in MegaLinter artifacts

Your project could benefit from a custom flavor, which would allow you to run only the linters you need, and thus improve runtime performances. (Skip this info by defining FLAVOR_SUGGESTIONS: false)

  • Documentation: Custom Flavors
  • Command: npx mega-linter-runner@9.6.0 --custom-flavor-setup --custom-flavor-linters PYTHON_BLACK,PYTHON_ISORT,COPYPASTE_JSCPD,JSON_V8R,JSON_PRETTIER,MARKDOWN_MARKDOWNLINT,MARKDOWN_MARKDOWN_TABLE_FORMATTER,REPOSITORY_CHECKOV,REPOSITORY_GIT_DIFF,REPOSITORY_GITLEAKS,REPOSITORY_BETTERLEAKS,REPOSITORY_SECRETLINT,REPOSITORY_SYFT,REPOSITORY_TRIVY_SBOM,REPOSITORY_TRUFFLEHOG,YAML_PRETTIER,YAML_YAMLLINT,YAML_V8R

MegaLinter is graciously provided by OX Security
Show us your support by starring ⭐ the repository

@FlorianPfaff
FlorianPfaff marked this pull request as ready for review July 26, 2026 12:27
@FlorianPfaff
FlorianPfaff enabled auto-merge (squash) July 26, 2026 12:27
@FlorianPfaff
FlorianPfaff merged commit 9ff3b62 into main Jul 26, 2026
25 checks passed
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

Successfully merging this pull request may close these issues.

1 participant