fix: restrict observability logging suggestion to Python only#222
Open
chundawat-h wants to merge 2 commits into
Open
fix: restrict observability logging suggestion to Python only#222chundawat-h wants to merge 2 commits into
chundawat-h wants to merge 2 commits into
Conversation
Updated the test count in README to reflect the current number of 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.
Description
This PR resolves a cross-language suggestion leakage bug where the Python-specific print/observability rule (
SUGGESTION 7: Logging) was running for all programming languages. This caused the analyzer to suggest Python-specific code snippets (likeimport loggingandlogger.info()) in reports for other languages like Java and C++.Related Issue
Fixes #156
Key changes:
backend/app/services/code_assistant.pyto only run whenlanguage == "Python".test_suggestions_observability_print_only_python()inbackend/tests/test_endpoints.pyto assert thatObservabilitysuggestions are not generated for Java but function correctly for Python.Type of Change
Testing
$env:RATE_LIMIT_PER_MINUTE=100; python -m pytest -vpasses with all 40 tests green)Checklist
mainpytest -vand all tests passfeat/fix/docs/test: short descriptionTest evidence
$env:RATE_LIMIT_PER_MINUTE=100; python -m pytest -v
====================================== test session starts ======================================
platform win32 -- Python 3.13.3, pytest-9.0.3, pluggy-1.6.0 -- C:\Python313\python.exe
cachedir: .pytest_cache
rootdir: D:\deta\Desktop\OpenSourceProjects\New folder\AI-dev-assistant\backend
plugins: anyio-4.13.0, asyncio-1.3.0
asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function
collected 52 items
tests/test_endpoints.py::test_root PASSED [ 1%]
tests/test_endpoints.py::test_health PASSED [ 3%]
tests/test_endpoints.py::test_rate_limit_headers_on_success_response PASSED [ 5%]
tests/test_endpoints.py::test_rate_limit_returns_429_with_retry_after_header PASSED [ 7%]
tests/test_endpoints.py::test_explanation_python PASSED [ 9%]
tests/test_endpoints.py::test_explanation_no_language_hint PASSED [ 11%]
tests/test_endpoints.py::test_explanation_rust PASSED [ 13%]
tests/test_endpoints.py::test_explanation_detects_rust_without_hint PASSED [ 15%]
tests/test_endpoints.py::test_explanation_accepts_rust_hint_alias PASSED [ 17%]
tests/test_endpoints.py::test_explanation_empty_code PASSED [ 19%]
tests/test_endpoints.py::test_explanation_too_long PASSED [ 21%]
tests/test_endpoints.py::test_explanation_typescript PASSED [ 23%]
tests/test_endpoints.py::test_explanation_java PASSED [ 25%]
tests/test_endpoints.py::test_explanation_cpp PASSED [ 26%]
tests/test_endpoints.py::test_explanation_cyclomatic_fields_present PASSED [ 28%]
tests/test_endpoints.py::test_explanation_cyclomatic_simple PASSED [ 30%]
tests/test_endpoints.py::test_explanation_cyclomatic_moderate PASSED [ 32%]
tests/test_endpoints.py::test_explanation_cyclomatic_high PASSED [ 34%]
tests/test_endpoints.py::test_explanation_cyclomatic_very_high PASSED [ 36%]
tests/test_endpoints.py::test_debug_detects_zero_division PASSED [ 38%]
tests/test_endpoints.py::test_debug_detects_hardcoded_secret PASSED [ 40%]
tests/test_endpoints.py::test_debug_detects_bare_except PASSED [ 42%]
tests/test_endpoints.py::test_debug_detects_eval PASSED [ 44%]
tests/test_endpoints.py::test_debug_clean_code PASSED [ 46%]
tests/test_endpoints.py::test_debug_javascript PASSED [ 48%]
tests/test_endpoints.py::test_debug_java PASSED [ 50%]
tests/test_endpoints.py::test_debug_cpp PASSED [ 51%]
tests/test_endpoints.py::test_explanation_php PASSED [ 53%]
tests/test_endpoints.py::test_explanation_detects_php_without_hint PASSED [ 55%]
tests/test_endpoints.py::test_debug_php PASSED [ 57%]
tests/test_endpoints.py::test_debug_php_buggy_patterns PASSED [ 59%]
tests/test_endpoints.py::test_debug_rust PASSED [ 61%]
tests/test_endpoints.py::test_debug_rust_buggy_patterns PASSED [ 63%]
tests/test_endpoints.py::test_debug_kotlin PASSED [ 65%]
tests/test_endpoints.py::test_debug_issue_has_required_fields PASSED [ 67%]
tests/test_endpoints.py::test_js_ts_security_patterns PASSED [ 69%]
tests/test_endpoints.py::test_suggestions_returns_score PASSED [ 71%]
tests/test_endpoints.py::test_suggestions_perfect_score PASSED [ 73%]
tests/test_endpoints.py::test_suggestions_observability_print_only_python PASSED [ 75%]
tests/test_endpoints.py::test_full_analyze PASSED [ 76%]
tests/test_endpoints.py::test_full_analyze_all_languages PASSED [ 78%]
tests/test_endpoints.py::test_missing_code_field PASSED [ 80%]
tests/test_endpoints.py::test_unicode_code PASSED [ 82%]
tests/test_endpoints.py::test_single_line_code PASSED [ 84%]
tests/test_ping.py::test_ping PASSED [ 86%]
tests/test_python_ast_analyzer.py::test_detects_missing_bracket_syntax_error PASSED [ 88%]
tests/test_python_ast_analyzer.py::test_detects_invalid_indentation_syntax_error PASSED [ 90%]
tests/test_python_ast_analyzer.py::test_detects_division_by_zero_expression PASSED [ 92%]
tests/test_python_ast_analyzer.py::test_detects_division_by_zero_inside_function_call PASSED [ 94%]
tests/test_python_ast_analyzer.py::test_detects_out_of_range_list_index PASSED [ 96%]
tests/test_python_ast_analyzer.py::test_detects_out_of_range_string_index PASSED [ 98%]
tests/test_python_ast_analyzer.py::test_detects_string_integer_concatenation PASSED [100%]
====================================== 52 passed in 1.56s =======================================