You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Improve usability and robustness by surfacing clear, user-facing errors for common operator mistakes like missing CSV files and malformed API parameters.
Harden the local UI API against abusive or accidental inputs by validating timeout values and CSV payload sizes to avoid confusing runtime failures.
Description
Convert analysis failures into a friendly exit message in the CLI by catching AnalysisError and FileNotFoundError in run_analyze and raising SystemExit with analysis error: ... instead of a raw traceback (bitnet_tools/cli.py).
Add stricter timeout parsing and bounds checking for the web API POST /api/run so non-integer timeout values are rejected and values outside 1..600 seconds return a clear HTTP error (bitnet_tools/web.py).
Add a regression test to assert the CLI path for a missing CSV file fails with a clear SystemExit message and expand tests exercising CSV parsing and summarization (tests/test_analysis.py).
Testing
Ran unit tests with python -m pytest -q, which returned 6 passed.
Verified CLI behavior with python -m bitnet_tools.cli analyze /tmp/does-not-exist.csv --question '점검' --out /tmp/nope.json, which exited with a friendly analysis error: CSV file not found and non-zero status.
Performed a web API smoke test by POSTing an invalid timeout (e.g. `
Values like NaN or inf are accepted as numeric and flow into summary statistics, but statistics.pstdev fails on non-finite numbers (ValueError/OverflowError), which crashes analysis for otherwise common CSV markers. This means build_analysis_payload can terminate with a traceback instead of returning a user-facing analysis error whenever a numeric column includes these tokens.
do_POST converts Content-Length with int(...) outside the request-validation try blocks, so a malformed header such as Content-Length: abc raises ValueError and aborts the handler thread instead of returning a 4xx JSON error. This makes malformed requests bypass the API's intended error handling path and produce server-side exceptions.
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
timeoutvalues and CSV payload sizes to avoid confusing runtime failures.Description
AnalysisErrorandFileNotFoundErrorinrun_analyzeand raisingSystemExitwithanalysis error: ...instead of a raw traceback (bitnet_tools/cli.py).timeoutparsing and bounds checking for the web APIPOST /api/runso non-integertimeoutvalues are rejected and values outside1..600seconds return a clear HTTP error (bitnet_tools/web.py).SystemExitmessage and expand tests exercising CSV parsing and summarization (tests/test_analysis.py).Testing
python -m pytest -q, which returned6 passed.python -m bitnet_tools.cli analyze /tmp/does-not-exist.csv --question '점검' --out /tmp/nope.json, which exited with a friendlyanalysis error: CSV file not foundand non-zero status.timeout(e.g. `Codex Task