Fix finance validation and write safety inconsistencies - #32
Merged
id774 merged 1 commit intoSep 12, 2026
Merged
Conversation
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QzJ43B843Qb2NNM2TZ1aYd
id774
deleted the
claude/fix-finance-validation-input-and-write-safety-3z4517
branch
September 12, 2026 10:21
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
--config/FINANCE_CONFIGfile that does not exist now failsas a
ConfigurationErrorinstead of silently falling back to defaults.ConfigurationError("...not valid YAML...")instead of an unhandled
yaml.YAMLErrortraceback.jquants.timeout/request_intervalrejectnan/inf/-infviamath.isfinite();retention_daysnow has aMIN_RETENTION_DAYS = 281floor, derived from
max(SMA_PERIODS) == 200and pinned bytest/test_plan_window.py.Settingstracks whetherhistory_dirwas explicitly configured(
FINANCE_HISTORY_DIR/paths.history_dir).--data-dirnow preservesan explicit history directory by provenance rather than by comparing it
to the derived default value.
finance-charts -y/--daysrejects negative values (usage error, exit 2);finance-summary -r/--rangerejects values below 1.finance/stocklist.pynow refuses a stock-list record with an emptyrequired code or name (
DataFormatError) instead of silently skipping it;only a true blank line (an empty CSV row, or a single whitespace-only
field) is skipped.
finance/datasources/jquants.py::_message()redacts the configuredAPI key (
str.replaceon every occurrence) from a provider error messagebefore truncation, so an echoed key cannot reach an exception, stderr or
the job log.
finance/storage.pywritesstock_CODE.csv,ti_CODE.csv, summarytables and
data_source.txtatomically: content is completed in asibling temporary file (created at mode
0o666 & umask) and moved ontothe target with
os.replace()only after the write succeeds; an existingtarget's mode/uid/gid are carried onto the replacement, and a failure at
any point leaves the last good target untouched.
ModelStore.save()andthe PNG writer are unchanged.
wording brought in line with the above, the stale "touches neither data/
nor clf/" deployment claim removed, the testing-group and command-count
text corrected, and
doc/VERSIONS' unreleased v1.0.2 entry consolidatedto the final state.
Compatibility
./config.ymlbehavior are unchanged.-y 0(all-history) meaning areunchanged.
formula (indicators, models, aggregation ratio) are unchanged.
cron.d/,run.shanddeploy.shruntime behavior are unchanged (notmodified).
pyproject.tomlchange, no newthird-party import.
key.
Version
1.0.2(pyproject.tomland
finance.__version__unchanged).doc/VERSIONStop entry remainsv1.0.2 (Release Date: TBD).finance/config.pyv1.2,finance/cli/__init__.pyv1.2,finance/cli/charts.pyv1.2,finance/cli/summary.pyv1.1,finance/stocklist.pyv1.1,finance/datasources/jquants.pyv1.2,finance/storage.pyv1.1. Testmodules were not version-bumped (assertions/coverage only).
Validation (actual results)
pytest: 513 passed, 2 deselected (integration), 1 pre-existing warning.ruff check .: All checks passed!sh -n run.sh: OKsh -n deploy.sh: OKgit diff --check: no whitespace errors🤖 Generated with Claude Code
https://claude.ai/code/session_01QzJ43B843Qb2NNM2TZ1aYd