8000 Hardening 1/4: entry points refuse bad input with a plain message, never a traceback by rafatahmed · Pull Request #118 · rafatahmed/Flahax · GitHub
[go: up one dir, main page]

Skip to content

Hardening 1/4: entry points refuse bad input with a plain message, never a traceback - #118

Merged
rafatahmed merged 2 commits into
mainfrom
fix/entry-points
Oct 23, 2026
Merged

rafatahmed merged 2 commits into
mainfrom
fix/entry-points

Conversation

@rafatahmed
Copy link
Copy Markdown
Owner

Closes #117.

First of four hardening PRs (entry points, errors, PEP 8 and file headers, docstrings), from the audit of 2026-10-23.

Changes

  • flahax batch --ratio 0 crashed (ZeroDivisionError). Every number option is now checked at the command line with its range: --ratio, --volume, --max-reagent-litres above 0; --ph 0-14; --water-share above 0 up to 100 ('--ratio must be above 0, not 0', exit 2).
  • One JSON reader for every file (water, targets, products, rules, saved items and sessions) names the file and the line and column ('water file well.json is not valid JSON: Unterminated string starting at line 1, column 2'); JSON on stdin (workflow, ec, size, the JSON request) gives the position too. New codes missing_file, invalid_json documented in the user guide.
  • A water value that is not a number is named ('water value Ca = 'lots' is not a number of mg/L'); a non-numeric --acid assay or density is named.
  • The flahax batch terminal now shows the acid at 0.1 mL like the sheet and report (the Full report still shows '0' g for small weights and rounds the acid differently from the sheet #108 rule, one more place).

Behaviour unchanged for valid input

A 97-result baseline (26 formulas through recommend, 26 formulas x RO and the station-104 well through the full batch pipeline, 19 farmer sweep sessions) is identical before and after.

Tests

tests/test_entry_inputs.py (ranges, named files, water and acid values, stdin positions, valid input unchanged). 534 tests with live PHREEQC required; tools/verify_distribution.py PASS; LF.

…nd line in JSON errors, plain acid and water messages (#117)
@read-the-docs-community
read-the-docs-community Bot commented Oct 23, 2026 •
Copy link
Copy Markdown

Documentation build overview

📚 Flahax | 🛠️ Build #35352080 | 📁 Comparing d3082fe against latest (4e7442f)

  🔍 Preview build  

2 files changed
± changelog.html
± guide/manual.html

@rafatahmed
rafatahmed merged commit fccba90 into main Oct 23, 2026
7 checks passed
@rafatahmed
rafatahmed deleted the fix/entry-points branch October 23, 2026 10:57
@rafatahmed rafatahmed self-assigned this Oct 23, 2026
rafatahmed added a commit that referenced this pull request Nov 7, 2026
Hardening 1/4: entry points refuse bad input with a plain message, never a traceback
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.

flahax batch --ratio 0 crashes with a ZeroDivisionError traceback; file and number errors are unclear

1 participant

0