Fix: 10 LOW-severity findings from bug bash#3182
Open
nankingjing wants to merge 1 commit into
Open
Conversation
…ragility) Groups of changes: - bare excepts -> typed exceptions * patch_handler._parse_diff_blocks: start_line parse catches (ValueError, IndexError) * messages.pretty_print_messages: tool-call args JSON parse catches (json.JSONDecodeError, TypeError) * validation._handle_validation_error: catches (KeyError, IndexError, TypeError, AttributeError) * session._get_pending_archive_messages: catches (FileNotFoundError, NotFoundError) * viking_fs._collect_uris: catches (FileNotFoundError, NotFoundError) - mutable defaults -> None factory * session_extract_context_provider.create_tool_context: default_search_uris=None - fragile fallbacks -> unique / safer * converter._convert_with_libreoffice: per-call mkdtemp + uuid-suffixed output * vikingbot get_or_create_machine_id: fallback uses uuid-suffixed 'default-<hex>' and logs - tautological test asserts -> real assertions * tests/integration/test_compressor_v2_e2e: 'assert True' replaced with task completion + listing type * tests/test_edge_cases test_directory_upload_with_circular_symlinks: asserts tuple shape + uploaded_count Tests: added tests/test_low_batch_regressions.py with 11 regression tests covering findings 1, 3, 4, 5, 10.
Contributor
Author
| Self-reviewed: diff is correct, minimal, and well-tested. No issues found. |
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
Process all 10 LOW-severity findings from the OpenViking bug bash into one commit, with regression tests for the easy-to-cover ones.
Fixes (by group)
Bare
except:/except Exception:-> typed exceptionsopenviking/session/memory/merge_op/patch_handler.py:832—start_lineparser now catches(ValueError, IndexError)instead of bareexcept.openviking/session/memory/utils/messages.py:69— tool-call arg JSON formatter now catches(json.JSONDecodeError, TypeError).openviking/storage/vectordb/utils/validation.py:265—_handle_validation_errornow catches(KeyError, IndexError, TypeError, AttributeError).openviking/session/session.py:2056/2065—_get_pending_archive_messagesnow catches(FileNotFoundError, NotFoundError); the latter is imported fromopenviking_cli.exceptions.openviking/storage/viking_fs.py:2916—_collect_urisnow catches(FileNotFoundError, NotFoundError)so unexpected errors still propagate.Mutable default argument -> None factory
openviking/session/memory/session_extract_context_provider.py:392—create_tool_context(default_search_uris=[])replaced withdefault=None+ a fresh list inside the method.Fragile fallbacks -> unique / safer
openviking/parse/converter.py:35—_convert_with_libreofficenow usestempfile.mkdtemp(prefix="ov-conv-")+ auuid.uuid4().hex[:8]suffix on the output PDF so concurrent conversions of files with the same stem can no longer collide.bot/vikingbot/cli/commands.py:130—get_or_create_machine_idfallback now returnsf"default-{uuid.uuid4().hex[:8]}"and the broadexcept Exceptionbranch now logs the failure vialoguru.logger.warning.Tautological test asserts -> real assertions
tests/integration/test_compressor_v2_e2e.py:231—assert Truereplaced withassert task_result["status"] == "completed"andassert isinstance(user_memories, list).tests/test_edge_cases.py:508— tautologicalassert result is None or result is not Nonereplaced with concrete assertions on the returned(uploaded_count, warnings)tuple (expects 1 uploaded file from the test fixture).Regression tests
Added
tests/test_low_batch_regressions.py(11 tests) covering findings 1, 3, 4, 5, 10:create_tool_contextmutable-default behaviour (signature default isNone, fresh list per call, explicit list passed through).pretty_print_messages.get_or_create_machine_idreturns unique fallbacks when themachineidimport is faked to fail (the function body is exec'd in an isolated namespace with stubbedloguru.logger).Verification
ruff formaton all 11 changed Python files (no diff).ruff checkon changed files: only pre-existingF401/F811warnings aboutToolPartinsession_extract_context_provider.py— unrelated to this PR.pytest tests/test_low_batch_regressions.py— 11/11 pass.Out-of-scope notes
patch_handler._parse_diff_blockswhereint(line.split(":")[1].strip())reads index 1 ("start_line") instead of index 2 (the actual number) is a deeper logic bug and is not addressed here. The batch only covered the type narrowing of the surroundingexcept. Testtest_patch_handler_start_line_ignores_malformed_header_without_crashingconfirms the narrowed except path returns 0 instead of crashing, without asserting a specific parsed value.