Conversation
- Add webhook_service.py with Slack integration - Implement threshold-based alerts (temp high/low, humidity high/low) - Add periodic status updates via APScheduler - Add webhook management API endpoints (/api/webhook/*) - Include retry logic with exponential backoff - Add 5-minute cooldown to prevent alert spam - Add webhook documentation and quickstart guide - Add test files for webhook and periodic updates - Update requirements.txt with requests and APScheduler 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Token should be generated manually and stored in .env file. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update CLAUDE.md with webhook endpoints and configuration - Update README.md with webhook setup instructions - Update Dockerfile for new dependencies - Add handoff documentation directory 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add Flask-RESTX for improved API structure and Swagger documentation - Introduce new webhook management endpoints: GET, PUT, POST for configuration, enabling, and disabling webhooks - Update requirements.txt to include flask-restx dependency - Refactor existing webhook routes to utilize Flask-RESTX resources This update enhances the API's usability and maintainability while providing better documentation for webhook interactions.
- Change 'url' field in webhook_config_input model to be optional for partial updates - Update description for 'url' to clarify its requirement during new webhook creation - Remove global security setting from API definition to allow public access to Swagger UI, while maintaining endpoint protection via decorators This update improves the flexibility of webhook configuration and enhances API accessibility.
Co-authored-by: baz-reviewer[bot] <174234987+baz-reviewer[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Created comprehensive test suite for Flask-RESTX webhook configuration API to ensure the bug fix at line 495 works correctly. Test coverage includes: - Creating webhook config when service doesn't exist (critical bug fix test) - Creating webhook config with missing URL (validation test) - Updating existing webhook configuration - Getting webhook config (exists and not exists scenarios) - Creating webhook with alert thresholds - Invalid threshold validation - Authentication and authorization tests All 9 tests pass successfully, verifying the AttributeError fix prevents crashes when creating new webhook service via API. Related to commit 9ffd7cb
Replace return statements with webhooks_ns.abort() in webhook endpoints to prevent @marshal_with decorator from dropping error keys during serialization. Affected endpoints: - POST /api/webhook/test (400 and 500 responses) - POST /api/webhook/enable (400 response) - POST /api/webhook/disable (400 response)
- Check for existing URL before allowing partial updates without URL - Preserve existing config values during partial updates instead of using hardcoded defaults - Prevents creating WebhookConfig with empty URL when webhook service exists but has no config
feat: Integrate Flask-RESTX for webhook management API
Flask-RESTX validation returns {message, errors} format which differs
from the existing {error, details} format that clients expect.
Manual validation in the handler still runs with consistent error format.
Hotfix/restx
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
…ature.py Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Flask-RESTX min/max constraints are OpenAPI docs only and not enforced at runtime. Add validate_webhook_config() to enforce: - retry_count: 1-10 - retry_delay: 1-60 seconds - timeout: 5-120 seconds Returns 400 with clear error message on violation.
…t of project restructuring. These documents are no longer needed for the current implementation and have been replaced by updated documentation practices.
…or project - Added CLAUDE.md to provide guidance on project architecture, API endpoints, and development commands. - Updated README.md to reflect the transition to Raspberry Pi 4 and included production deployment strategies. - Enhanced Dockerfile and docker-compose.yml with health checks and resource limits for optimized performance. - Introduced WSGI entry point for production deployment and a startup script for easier service management. - Added systemd service configuration for automated deployment and monitoring. - Included detailed production deployment guide in docs/PI4_DEPLOYMENT.md. - Updated various files to ensure consistency with the new Raspberry Pi 4 setup and improved documentation practices.
- Add generate_error_id() for tracking errors across logs and responses - Use logging.exception() to capture full stack traces in logs - Return error_id instead of internal exception details to clients - Improves security by not exposing internals while aiding debugging
- Updated API response to mask webhook URLs, revealing only the scheme and host to prevent exposure of sensitive tokens. - Introduced a new function to handle URL masking in the WebhookService and updated relevant logging statements. - Added unit tests to verify that webhook URLs are masked correctly in API responses.
…ng and logging - Added new log entries in temp_monitor.log for webhook service configuration issues and API access attempts with invalid tokens. - Enhanced error handling in temp_monitor.py by replacing specific error messages with a generic 'Internal server error' for health and metrics endpoints, while using logging.exception for better error tracking.
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
- App now exits with code 1 if BEARER_TOKEN is not set instead of running in a degraded state with broken API endpoints - Fixed README documentation that incorrectly stated token was "auto-generated if not provided"
Convert test_webhook.py from placeholder print statements to proper unittest framework with 29 tests across 8 test classes: - Use unittest.mock.patch to capture payloads without network calls - Verify Slack payload structure (attachments, color, text, ts, fields) - Assert field content, ordering, and short flags - Confirm requests.post is never called when enabled=False - Test all message types: basic, alerts, status updates, system events
…, locator, pattern finder, web search researcher, and commit commands. These files are no longer needed as part of the project restructuring and have been replaced by updated documentation practices.
…or project - Introduced AGENTS.md to provide detailed guidance on project architecture, API endpoints, and development commands. - Documented core layers including Flask application, webhook service, and API models. - Outlined public and protected routes, configuration settings, key design patterns, and testing strategies. - Included common issues and solutions to assist developers in troubleshooting.
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Resolve merge conflicts by accepting error correlation ID additions: - Webhook config update error handler - Test webhook error handler - Health check error handler - System metrics collection error - Metrics endpoint error handler 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Updated project title and description for better clarity. - Enhanced the features section with detailed descriptions and added new features like Swagger documentation and Docker support. - Reorganized installation and configuration instructions for improved readability. - Added a comprehensive table of contents for easier navigation. - Included new sections on webhook notifications, alert thresholds, and troubleshooting. - Removed outdated installation steps and streamlined the quick start guide. - Deleted the exception-details subproject as it is no longer needed.
- Replaced instances of 'docker-compose' with 'docker compose' across AGENTS.md, CLAUDE.md, README.md, and PI4_DEPLOYMENT.md for uniformity and to align with the latest Docker CLI standards.
- Introduced CLOUDFLARED_TOKEN in .env.example for Cloudflare Tunnel configuration. - Added cloudflared service to docker-compose.yml for tunnel management. - Updated README and PI4_DEPLOYMENT.md to include instructions for setting up the Cloudflare Tunnel. - Created LICENSE file to clarify project licensing.
Add environment selection input (production/testing) to workflow_dispatch trigger, allowing developers to manually deploy feature branches to the self-hosted runner for testing before merging to main. Changes: - Add 'environment' input with production/testing options (defaults to testing) - Clarify deploy_ref description (remove "manual runs only") - Add deployment info display step showing event, ref, and environment - Document deploy conditions in workflow comments
- Clarified the optional nature of SLACK_WEBHOOK_URL in .env.example and README.md. - Enhanced health check command in docker-compose.yml for better monitoring. - Added cloudflare profile support in docker-compose.yml and updated deployment instructions in PI4_DEPLOYMENT.md. - Improved GitHub Actions workflow to validate required secrets and streamline .env creation. - Removed outdated HANDOFF.md documentation as part of project cleanup.
- Changed STATUS_UPDATE_ENABLED to true in ci.yml to activate status updates. - Added STATUS_UPDATE_ON_STARTUP to ensure updates are sent at startup.
|
Skipped: This PR does not contain any of your configured labels: ( |
|
Caution Review failedThe pull request is closed. WalkthroughThis pull request transforms a basic Raspberry Pi temperature monitor into a production-ready Flask application with Slack webhook notifications, API-driven configuration, health checks, Docker/systemd deployment infrastructure, and comprehensive documentation. It introduces webhook service, API models, WSGI entry point, test suites, and CI/CD automation. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Sensor as Sensor Thread
participant App as Flask App
participant WS as Webhook Service
participant Slack as Slack API
rect rgb(220, 240, 220)
Note over Sensor,Slack: Temperature Alert Flow
Sensor->>Sensor: Read temp/humidity
Sensor->>App: Update readings
App->>WS: check_and_alert(temp, humidity)
alt Temperature exceeds threshold
WS->>WS: Check cooldown & enabled
alt Can send alert
WS->>WS: Format Slack payload<br/>(color, icon, fields)
WS->>Slack: POST webhook<br/>(with retry logic)
Slack-->>WS: 200 OK
WS->>WS: Mark alert sent<br/>(set cooldown)
WS-->>App: {alert_type: true}
else Still in cooldown
WS-->>App: {alert_type: false}
end
else Within normal range
WS-->>App: {alert_type: false}
end
end
rect rgb(220, 220, 240)
Note over Sensor,Slack: Periodic Status Update Flow
Sensor->>WS: send_status_update(<br/>temp, humidity, cpu_temp)
WS->>WS: Format status payload<br/>(fields: temp, humidity, CPU, timestamp)
WS->>Slack: POST webhook<br/>(with timeout & retries)
Slack-->>WS: 200 OK
WS-->>Sensor: success: true
end
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly Related PRs
Poem
✨ Finishing touches
📜 Recent review detailsConfiguration used: Organization UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (24)
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. Comment |
|
@ |
greptile
Summary by CodeRabbit
New Features
Infrastructure
Documentation
✏️ Tip: You can customize this high-level summary in your review settings.