Fix garbled Chinese log messages, bare except clauses, and unsafe empty-list access in EIS processing#1
Merged
Conversation
…t debug prints to logging - Fix ~20 garbled/corrupted Chinese print messages in processing_lsv.py get_ir_from_eis() - Add empty-list guard after _filter_outliers() to prevent potential crash - Convert all print() calls to log() in processing_lsv.py for consistent logging - Replace 8 bare except: clauses with except Exception: or except (ValueError, TypeError): in processing_cv.py, processing_eis.py, processing_ecsa.py, tool_executor.py - Replace debug print() statements with logging.debug() in agent_controller.py and tool_executor.py Co-authored-by: Sunnnnch <147936020+Sunnnnch@users.noreply.github.com>
Address code review feedback: restructure the empty-list guard after _filter_outliers() so it properly protects the entire high-frequency analysis block, not just the log message. Co-authored-by: Sunnnnch <147936020+Sunnnnch@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Check for issues in current repository
Fix garbled Chinese log messages, bare except clauses, and debug prints in production code
Mar 11, 2026
Copilot
AI
changed the title
Fix garbled Chinese log messages, bare except clauses, and debug prints in production code
Fix garbled Chinese log messages, bare except clauses, and unsafe empty-list access in EIS processing
Mar 11, 2026
added 2 commits
March 11, 2026 13:46
- Remove LLM API key from log output (routes_post) - Add path traversal protection (tool_executor, vision_client, routes_post) - Add safe integer parsing with clamping (routes_get) - Add parameter whitelist validation for sort_by/chart_type (routes_get) - Add CSP and X-Content-Type-Options headers (http_server) - Fix _sanitize_filename directory traversal via os.path.basename (processing_core_v6) - Add .bak backup before JSON writes (history, projects) - Replace silent exception swallowing with logging (projects) - Fix matplotlib figure leak with try-finally (processing_lsv) - Fix garbled error message in request_utils - Extract shared utils (as_float/as_int/as_bool) to eliminate duplication - Add centralized path_security module - Pin dependency version ranges (requirements-pack)
…s, improve robustness - Split tool_executor.py (860 lines) into thin dispatcher + tools_data.py + tools_projects.py - Add project name validation (length limit 128, control char stripping) in store/projects.py - Extract magic numbers to named constants in processing_lsv.py (MAD thresholds, fitting defaults, EIS thresholds, SOFTWARE_VERSION) - Add shared read_file_with_fallback_encodings() utility to core/utils.py - Replace inline encoding loops in processing_cv/eis/lsv with shared utility - Fix bare except blocks: narrow to (ValueError, TypeError) in LSV Tafel fitting, parse helpers - Add try-finally around plt.savefig in CV, EIS (Nyquist+Bode), LSV IR-compensated plots - Fix CV peaks bare except to log instead of silently swallowing - Add 17 tests for path_security module - Add 17+ tests for utils module (as_float, as_int, as_bool, read_file_with_fallback_encodings) - Add 11 tests for project input validation All 103 tests pass (92 existing + 11 new validation tests).
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.
Repository audit found ~20 corrupted Chinese strings in
get_ir_from_eis(), unsafe bareexcept:clauses across 4 files, and a potential crash when_filter_outliers()returns empty lists.Garbled Chinese text in
processing_lsv.pyAll log messages in
get_ir_from_eis()had corrupted characters rendering them unreadable. Reconstructed with correct Chinese and switched fromprint()tolog().Empty-list guard after
_filter_outliers()_filter_outliers()can return empty lists, causingValueErroron subsequentmin()/max()calls. Added a guard that skips the entire high-frequency analysis block when filtered data is empty.Bare
except:→ typed exceptions8 bare
except:clauses (which swallowKeyboardInterrupt,SystemExit, etc.) replaced acrossprocessing_cv.py,processing_eis.py,processing_ecsa.py,tool_executor.pywithexcept Exception:orexcept (ValueError, TypeError):as appropriate.Debug
print()→logging.debug()3
print(f"[DEBUG] ...")calls inagent_controller.pyandtool_executor.pyreplaced with_logger.debug(). 10 additionalprint()calls in the Tafel export section ofprocessing_lsv.pyconverted tolog()for consistency.💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.