feat: Add exception telemetry#9194
Conversation
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Fixed 4 failing tests in test_validate.py: - test_code_with_syntax_error: Better error message handling for syntax errors - test_raises_error_for_missing_function: Handle StopIteration along with ValueError - test_creates_simple_class: Use optional constructor parameter to avoid TypeError - test_handles_validation_error: Use proper ValidationError constructor from pydantic_core - test_creates_context_with_langflow_imports: Remove invalid module patching - test_creates_mock_classes_on_import_failure: Use proper import mocking All 50 validate tests now pass consistently, improving CI stability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Added 6 additional test cases to improve coverage of template_validation.py: - test_validate_stream_exception: Tests Graph.validate_stream() exception handling - test_code_validation_other_exceptions: Tests TypeError/KeyError/AttributeError handling - test_vertices_sorted_without_end_vertex_events: Tests variable usage tracking - test_vertex_count_tracking: Tests vertex_count increment paths - test_empty_lines_in_stream: Tests empty line handling in event streams - test_event_stream_validation_exception: Tests exception handling in _validate_event_stream These tests target the remaining 7 uncovered lines to maximize coverage percentage. Total tests: 40 (all passing) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Add comprehensive exception telemetry to capture and send unhandled exceptions to Scarf analytics for better error tracking and debugging. Features: - ExceptionPayload schema with type, message, context, and stack hash - TelemetryService.log_exception() method for exception logging - Integration in FastAPI exception handlers and lifespan events - Stack trace hashing for grouping similar exceptions - Respects existing do_not_track privacy settings Context tracking: - "handler" - exceptions in HTTP request processing - "lifespan" - exceptions during app startup/shutdown Sends data to: https://langflow.gateway.scarf.sh/exception Includes comprehensive unit and integration tests covering all functionality and edge cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Replace MD5 with SHA256 for better security practices - Use contextlib.suppress instead of try-except-pass patterns - Fix telemetry_service scope issue in lifespan function - Improve test exception handling to follow best practices - All linting checks now pass with proper code style 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThis update introduces comprehensive validation and testing infrastructure for Langflow starter project templates. It adds new validation utilities, extensive unit and integration tests, a dedicated GitHub Actions workflow, pre-commit hook, and Makefile targets for template testing. Additionally, it implements telemetry exception logging throughout the FastAPI app and enhances the telemetry service and schema. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant GitHub Actions
participant Pre-commit
participant Makefile
participant TestRunner
participant TemplateValidation
participant TelemetryService
participant FastAPI
User->>GitHub Actions: Push/PR triggers workflow
GitHub Actions->>TestRunner: Run test_starter_projects.py
TestRunner->>TemplateValidation: Validate templates (structure, build, code, execution)
TemplateValidation-->>TestRunner: Validation results
User->>Pre-commit: Commit starter project JSON
Pre-commit->>TestRunner: Run template validation with security check
User->>Makefile: make template_tests
Makefile->>TestRunner: Run pytest on test_starter_projects.py
FastAPI->>TelemetryService: On exception, call log_exception
TelemetryService->>TelemetryService: Hash stack trace, build ExceptionPayload
TelemetryService->>Telemetry Backend: Send telemetry data
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested labels
Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
|
Codecov Report❌ Patch coverage is
❌ Your project status has failed because the head coverage (2.71%) is below the target coverage (10.00%). You can increase the head coverage or adjust the target coverage. Additional details and impacted files@@ Coverage Diff @@
## main #9194 +/- ##
==========================================
+ Coverage 32.45% 32.88% +0.42%
==========================================
Files 1217 1198 -19
Lines 57572 56989 -583
Branches 5373 5232 -141
==========================================
+ Hits 18687 18738 +51
+ Misses 38825 38191 -634
Partials 60 60
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
* add template tests * remove files * adding validate flow build * add validate endpoint and flow execution * Update .github/workflows/template-tests.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update src/backend/base/langflow/utils/template_validation.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * [autofix.ci] apply automated fixes * change workflow running * add ci * fix test * fix test * delete when push * fix: Exclude template tests from unit test bundle Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Exclude template tests from unit test bundle Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Exclude template tests from unit test bundle Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Remove remaining merge conflict markers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Improve validate.py unit tests to eliminate CI failures Fixed 4 failing tests in test_validate.py: - test_code_with_syntax_error: Better error message handling for syntax errors - test_raises_error_for_missing_function: Handle StopIteration along with ValueError - test_creates_simple_class: Use optional constructor parameter to avoid TypeError - test_handles_validation_error: Use proper ValidationError constructor from pydantic_core - test_creates_context_with_langflow_imports: Remove invalid module patching - test_creates_mock_classes_on_import_failure: Use proper import mocking All 50 validate tests now pass consistently, improving CI stability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * enhance: Add comprehensive edge case tests for template_validation.py Added 6 additional test cases to improve coverage of template_validation.py: - test_validate_stream_exception: Tests Graph.validate_stream() exception handling - test_code_validation_other_exceptions: Tests TypeError/KeyError/AttributeError handling - test_vertices_sorted_without_end_vertex_events: Tests variable usage tracking - test_vertex_count_tracking: Tests vertex_count increment paths - test_empty_lines_in_stream: Tests empty line handling in event streams - test_event_stream_validation_exception: Tests exception handling in _validate_event_stream These tests target the remaining 7 uncovered lines to maximize coverage percentage. Total tests: 40 (all passing) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Add telemetry for unhandled exceptions Add comprehensive exception telemetry to capture and send unhandled exceptions to Scarf analytics for better error tracking and debugging. Features: - ExceptionPayload schema with type, message, context, and stack hash - TelemetryService.log_exception() method for exception logging - Integration in FastAPI exception handlers and lifespan events - Stack trace hashing for grouping similar exceptions - Respects existing do_not_track privacy settings Context tracking: - "handler" - exceptions in HTTP request processing - "lifespan" - exceptions during app startup/shutdown Sends data to: https://langflow.gateway.scarf.sh/exception Includes comprehensive unit and integration tests covering all functionality and edge cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Improve exception telemetry implementation - Replace MD5 with SHA256 for better security practices - Use contextlib.suppress instead of try-except-pass patterns - Fix telemetry_service scope issue in lifespan function - Improve test exception handling to follow best practices - All linting checks now pass with proper code style 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor the exception logging * [autofix.ci] apply automated fixes * update comment * use mock url * fix: remove telemetry logging for lifespan cancellation during shutdown --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>
* add template tests * remove files * adding validate flow build * add validate endpoint and flow execution * Update .github/workflows/template-tests.yml Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * Update src/backend/base/langflow/utils/template_validation.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * [autofix.ci] apply automated fixes * change workflow running * add ci * fix test * fix test * delete when push * fix: Exclude template tests from unit test bundle Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Exclude template tests from unit test bundle Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Exclude template tests from unit test bundle Template tests are already run separately in CI via the test-templates job. This change prevents duplicate execution and eliminates timeout failures in the unit test suite by excluding slow template execution tests. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Remove remaining merge conflict markers 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Improve validate.py unit tests to eliminate CI failures Fixed 4 failing tests in test_validate.py: - test_code_with_syntax_error: Better error message handling for syntax errors - test_raises_error_for_missing_function: Handle StopIteration along with ValueError - test_creates_simple_class: Use optional constructor parameter to avoid TypeError - test_handles_validation_error: Use proper ValidationError constructor from pydantic_core - test_creates_context_with_langflow_imports: Remove invalid module patching - test_creates_mock_classes_on_import_failure: Use proper import mocking All 50 validate tests now pass consistently, improving CI stability. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * enhance: Add comprehensive edge case tests for template_validation.py Added 6 additional test cases to improve coverage of template_validation.py: - test_validate_stream_exception: Tests Graph.validate_stream() exception handling - test_code_validation_other_exceptions: Tests TypeError/KeyError/AttributeError handling - test_vertices_sorted_without_end_vertex_events: Tests variable usage tracking - test_vertex_count_tracking: Tests vertex_count increment paths - test_empty_lines_in_stream: Tests empty line handling in event streams - test_event_stream_validation_exception: Tests exception handling in _validate_event_stream These tests target the remaining 7 uncovered lines to maximize coverage percentage. Total tests: 40 (all passing) 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * feat: Add telemetry for unhandled exceptions Add comprehensive exception telemetry to capture and send unhandled exceptions to Scarf analytics for better error tracking and debugging. Features: - ExceptionPayload schema with type, message, context, and stack hash - TelemetryService.log_exception() method for exception logging - Integration in FastAPI exception handlers and lifespan events - Stack trace hashing for grouping similar exceptions - Respects existing do_not_track privacy settings Context tracking: - "handler" - exceptions in HTTP request processing - "lifespan" - exceptions during app startup/shutdown Sends data to: https://langflow.gateway.scarf.sh/exception Includes comprehensive unit and integration tests covering all functionality and edge cases. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * fix: Improve exception telemetry implementation - Replace MD5 with SHA256 for better security practices - Use contextlib.suppress instead of try-except-pass patterns - Fix telemetry_service scope issue in lifespan function - Improve test exception handling to follow best practices - All linting checks now pass with proper code style 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com> * refactor the exception logging * [autofix.ci] apply automated fixes * update comment * use mock url * fix: remove telemetry logging for lifespan cancellation during shutdown --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Gabriel Luiz Freitas Almeida <gabriel@langflow.org>



This pull request introduces exception telemetry logging to the
langflowbackend, enabling better tracking and analysis of unhandled exceptions. Key changes include adding a new telemetry payload schema for exceptions, implementing a method to log exceptions to the telemetry service, and adding unit and integration tests to validate the functionality.Telemetry Enhancements:
ExceptionPayloadto the telemetry schema to capture exception details, including type, message, context, and a stack trace hash for grouping similar exceptions (src/backend/base/langflow/services/telemetry/schema.py).log_exceptionin the telemetry service to log unhandled exceptions with context and a hashed stack trace for grouping (src/backend/base/langflow/services/telemetry/service.py).Exception Logging Integration:
lifespanandexception_handlermethods, ensuring exceptions are captured and reported to the telemetry service (src/backend/base/langflow/main.py) [1] [2] [3].Testing:
ExceptionPayloadschema,log_exceptionmethod, and telemetry service behavior, including respect for thedo_not_tracksetting (src/backend/tests/unit/test_exception_telemetry.py).src/backend/tests/integration/test_exception_telemetry.py).