Skip to content

Hotfix/workflow#37

Merged
fakebizprez merged 3 commits intomasterfrom
hotfix/workflow
Jan 3, 2026
Merged

Hotfix/workflow#37
fakebizprez merged 3 commits intomasterfrom
hotfix/workflow

Conversation

@fakebizprez
Copy link
Copy Markdown
Member

@fakebizprez fakebizprez commented Jan 3, 2026

Summary by CodeRabbit

  • Configuration & Alerts

    • Temperature alert threshold updated to 32°C (previously 27°C)
    • Humidity alert threshold updated to 20% (previously 30%)
  • Deployment

    • Cloudflare token validation added to CI/CD pipeline

✏️ Tip: You can customize this high-level summary in your review settings.

- Added validation for the required CLOUDFLARED_TOKEN in the CI workflow to ensure necessary secrets are present before deployment.
- Updated the Docker Compose command to specify the cloudflare profile during deployment, improving clarity and functionality.
- Removed outdated research documentation related to Pydantic validation, streamlining the project structure.
- Increased maximum temperature alert threshold from 27°C to 32°C in .env.example and corresponding code files.
- Decreased minimum humidity alert threshold from 30% to 20% in .env.example and updated related code references in temp_monitor.py and webhook_service.py.
@fakebizprez fakebizprez self-assigned this Jan 3, 2026
@fakebizprez fakebizprez added the bug Something isn't working label Jan 3, 2026
@fakebizprez
Copy link
Copy Markdown
Member Author

@greptileai

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 3, 2026

Warning

Rate limit exceeded

@fakebizprez has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 58 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 76e242e and fcc0df6.

📒 Files selected for processing (2)
  • .github/workflows/ci.yml
  • README.md

Walkthrough

This PR updates alert threshold defaults across configuration and code files (ALERT_TEMP_MAX_C: 27.0→32.0, ALERT_HUMIDITY_MIN: 30.0→20.0), adds mandatory CLOUDFLARED_TOKEN validation to the CI deployment workflow with Cloudflare profile enablement, and removes research documentation on Pydantic validation implementation.

Changes

Cohort / File(s) Summary
Alert threshold defaults
webhook_service.py, temp_monitor.py, .env.example
Default values for temp_max_c changed from 27.0 to 32.0 and humidity_min changed from 30.0 to 20.0; threshold logic remains unchanged
CI deployment workflow
.github/workflows/ci.yml
Added mandatory CLOUDFLARED_TOKEN secret validation; deploy step now exits with error if token missing; deployment command updated with --profile cloudflare flag
Documentation cleanup
thoughts/tasks/issue-24-pydantic-validation/2025-12-31-research.md
Removed entire research file documenting Pydantic validation investigation for Issue #24

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested labels

greptile

Poem

A rabbit adjusts the thresholds with care, 🐰
Temperatures rising, humidity's fair,
The Cloudflare token now checks in the flow,
Old research discarded—new configs aglow!
Thirty-two degrees, a warmer affair. ☀️

Pre-merge checks and finishing touches

❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'Hotfix/workflow' is vague and generic, using non-descriptive terms that don't convey meaningful information about the specific changes made. Use a more descriptive title that clearly summarizes the main changes, such as 'Update alert thresholds and add Cloudflare deployment profile' or 'Fix CI workflow and adjust monitoring thresholds'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 3, 2026

Greptile Summary

This PR updates alert threshold defaults and enhances the CI/CD workflow for cloudflare tunnel deployment.

Key Changes:

  • Updated temperature max threshold from 27°C (80.6°F) to 32°C (90°F) across all default values
  • Updated humidity min threshold from 30% to 20% across all default values
  • Added CLOUDFLARED_TOKEN validation to CI workflow deployment step
  • Updated docker compose deployment to use --profile cloudflare flag
  • Removed completed research documentation file

Issue Found:

  • Critical inconsistency: CI workflow hardcodes old threshold values (27°C, 30%) in production deployment while all other files use new values (32°C, 20%)

Confidence Score: 2/5

  • This PR has a critical configuration inconsistency that will cause production to use different thresholds than intended
  • While the threshold updates are straightforward and the cloudflare deployment enhancements are correct, the hardcoded values in .github/workflows/ci.yml don't match the updated defaults in all other files. This means production deployments will use 27°C max temp and 30% min humidity instead of the intended 32°C and 20% values, creating unexpected behavior and defeating the purpose of this PR.
  • .github/workflows/ci.yml requires immediate attention to fix inconsistent threshold values before merging

Important Files Changed

Filename Overview
.env.example Updated alert threshold defaults (temp max: 27°C → 32°C, humidity min: 30% → 20%), matching documentation comments
.github/workflows/ci.yml Added CLOUDFLARED_TOKEN validation and cloudflare profile to deployment, but hardcoded thresholds are inconsistent with other files
temp_monitor.py Updated default alert thresholds in code to match new values (temp max: 32°C, humidity min: 20%)
webhook_service.py Updated AlertThresholds dataclass defaults (temp max: 27°C → 32°C, humidity min: 30% → 20%)

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant GH as GitHub Actions
    participant Secrets as GitHub Secrets
    participant Runner as Self-Hosted Runner
    participant Docker as Docker Compose
    participant App as Temp Monitor App
    participant CF as Cloudflare Tunnel

    Dev->>GH: Push to master / Release / Manual trigger
    GH->>GH: Run tests job (ubuntu-latest)
    GH->>Runner: Trigger deploy job (self-hosted)
    
    Runner->>Secrets: Fetch BEARER_TOKEN
    Runner->>Secrets: Fetch CLOUDFLARED_TOKEN
    Runner->>Secrets: Fetch SLACK_WEBHOOK_URL (optional)
    
    alt Missing BEARER_TOKEN or CLOUDFLARED_TOKEN
        Runner->>GH: Exit with error
    end
    
    Runner->>Runner: Create .env file with secrets
    Runner->>Runner: Add hardcoded thresholds (OLD VALUES)
    Note over Runner: ALERT_TEMP_MAX_C=27.0<br/>ALERT_HUMIDITY_MIN=30.0
    
    Runner->>Docker: docker compose --profile cloudflare up -d --build
    Docker->>App: Start temp-monitor container
    Docker->>CF: Start cloudflared container (with CLOUDFLARED_TOKEN)
    
    App->>App: Load .env configuration
    Note over App: Uses OLD thresholds from CI<br/>instead of NEW defaults (32.0, 20.0)
    
    CF->>CF: Establish tunnel to Cloudflare network
    CF-->>App: Proxy external traffic
Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additional Comments (1)

  1. .github/workflows/ci.yml, line 101-104 (link)

    logic: hardcoded alert thresholds in CI workflow don't match the updated defaults

    The CI workflow still uses old values (ALERT_TEMP_MAX_C=27.0 and ALERT_HUMIDITY_MIN=30.0) while all other files were updated to new defaults (ALERT_TEMP_MAX_C=32.0 and ALERT_HUMIDITY_MIN=20.0). This creates inconsistency between local development and production deployments.

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
.github/workflows/ci.yml (1)

102-104: Update production thresholds to match new defaults.

The hardcoded production thresholds still use the old values (27.0°C max, 30.0% min humidity), creating an inconsistency with the updated defaults throughout the codebase (32.0°C max, 20.0% min humidity). This means production will trigger alerts at different thresholds than development environments.

🔎 Proposed fix to align production thresholds
-          echo "ALERT_TEMP_MAX_C=27.0" >> .env
-          echo "ALERT_HUMIDITY_MIN=30.0" >> .env
+          echo "ALERT_TEMP_MAX_C=32.0" >> .env
+          echo "ALERT_HUMIDITY_MIN=20.0" >> .env
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8466b17 and 76e242e.

📒 Files selected for processing (5)
  • .env.example
  • .github/workflows/ci.yml
  • temp_monitor.py
  • thoughts/tasks/issue-24-pydantic-validation/2025-12-31-research.md
  • webhook_service.py
💤 Files with no reviewable changes (1)
  • thoughts/tasks/issue-24-pydantic-validation/2025-12-31-research.md
🧰 Additional context used
📓 Path-based instructions (3)
.env.example

📄 CodeRabbit inference engine (CLAUDE.md)

Generate API Bearer token using python3 -c "import secrets; print(secrets.token_hex(32))" and store securely in .env file

Files:

  • .env.example
**/*.py

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.py: Implement thread safety for global state (current_temp, current_humidity) as read-only from thread perspective, and use threading.Lock() for concurrent access to mutable shared state in WebhookService
Use Bearer token authentication via @require_token decorator on protected API endpoints, with 401 (missing header) vs 403 (invalid token) distinction
Implement sensor data quality with multiple readings, outlier filtering (removes min/max), CPU heat compensation formula, and cached readings accessed by multiple endpoints
Implement webhook reliability with alert cooldown (5 minutes between same alert type), exponential backoff retry logic (delay = initial_delay × 2^(attempt_number)), and configurable retry count (1-10) and timeout (5-120 seconds)
Implement Slack webhook notification formatting through WebhookService.send_slack_message() with proper JSON payload structure and thread-safe operations
Use Flask-RESTX namespace for defining OpenAPI/Swagger models with input validation constraints (e.g., retry_count 1-10, timeout 5-120 seconds) and cross-field validation functions
Implement sensor compensation with CPU heat factor 0.7 and -4°F correction in get_compensated_temperature(), taking 10 readings (5 from humidity + 5 from pressure sensors) with outlier filtering
Apply +4% correction to humidity readings with 3 readings and outlier filtering in get_humidity()
Use environment variables from .env file for configuration (LOG_FILE, BEARER_TOKEN, SLACK_WEBHOOK_URL, WEBHOOK_, ALERT_, STATUS_UPDATE_) managed through python-dotenv
Implement Flask routes for public endpoints (/, /docs, /health, /metrics) without authentication and protected endpoints (/api/temp, /api/raw, /api/verify-token, /api/webhook/
) requiring Bearer token
Include /health endpoint for monitoring/load balancer compatibility and /metrics endpoint with psutil system stats support

Files:

  • temp_monitor.py
  • webhook_service.py
**/temp_monitor.py

📄 CodeRabbit inference engine (CLAUDE.md)

Document temperature calibration by adjusting factor parameter in get_compensated_temperature() based on actual readings to compensate for CPU heat effects

Files:

  • temp_monitor.py
🧠 Learnings (13)
📓 Common learnings
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/test_*.py : Include critical test coverage for: webhook config creation when webhook_service is None (AttributeError bug fix), threshold validation (cross-field min/max relationships), alert cooldown preventing duplicate alerts, and exponential backoff retry logic
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/*.py : Implement sensor compensation with CPU heat factor 0.7 and -4°F correction in get_compensated_temperature(), taking 10 readings (5 from humidity + 5 from pressure sensors) with outlier filtering
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Use consistent JSON API response format with fields: temperature_c, temperature_f, humidity, timestamp

Applied to files:

  • temp_monitor.py
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/temp_monitor.py : Document temperature calibration by adjusting factor parameter in get_compensated_temperature() based on actual readings to compensate for CPU heat effects

Applied to files:

  • temp_monitor.py
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/*.py : Implement sensor compensation with CPU heat factor 0.7 and -4°F correction in get_compensated_temperature(), taking 10 readings (5 from humidity + 5 from pressure sensors) with outlier filtering

Applied to files:

  • temp_monitor.py
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Use environment variables (loaded via python-dotenv) for configurable paths: LOG_FILE, LOGO_PATH, FAVICON_PATH, BEARER_TOKEN

Applied to files:

  • temp_monitor.py
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : For temperature sensor readings, remove highest and lowest outlier values before averaging to improve accuracy

Applied to files:

  • temp_monitor.py
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Use daemon threads for background monitoring tasks (sensor data collection) with appropriate sampling intervals (default 60 seconds)

Applied to files:

  • temp_monitor.py
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/test_*.py : Include critical test coverage for: webhook config creation when webhook_service is None (AttributeError bug fix), threshold validation (cross-field min/max relationships), alert cooldown preventing duplicate alerts, and exponential backoff retry logic

Applied to files:

  • webhook_service.py
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/*.py : Implement webhook reliability with alert cooldown (5 minutes between same alert type), exponential backoff retry logic (delay = initial_delay × 2^(attempt_number)), and configurable retry count (1-10) and timeout (5-120 seconds)

Applied to files:

  • webhook_service.py
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to **/*.py : Implement thread safety for global state (current_temp, current_humidity) as read-only from thread perspective, and use threading.Lock() for concurrent access to mutable shared state in WebhookService

Applied to files:

  • webhook_service.py
📚 Learning: 2025-11-27T09:21:56.117Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T09:21:56.117Z
Learning: Applies to **/temp_monitor.py : Store BEARER_TOKEN in .env file (never committed to git) and load at application startup; auto-generate token if .env is missing

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to .env.example : Generate API Bearer token using python3 -c "import secrets; print(secrets.token_hex(32))" and store securely in .env file

Applied to files:

  • .github/workflows/ci.yml
📚 Learning: 2026-01-03T19:06:09.139Z
Learnt from: CR
Repo: freightCognition/temp_monitor PR: 0
File: CLAUDE.md:0-0
Timestamp: 2026-01-03T19:06:09.139Z
Learning: Applies to {Dockerfile,docker-compose.yml} : Use Docker Compose with ARM build support for deployment and include privileged mode, I2C device mounting, and /sys read-only access for hardware interaction

Applied to files:

  • .github/workflows/ci.yml
🪛 dotenv-linter (4.0.0)
.env.example

[warning] 32-32: [UnorderedKey] The ALERT_TEMP_MAX_C key should go before the ALERT_TEMP_MIN_C key

(UnorderedKey)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Greptile Review
  • GitHub Check: Greptile Review
🔇 Additional comments (5)
.env.example (1)

30-37: LGTM! Threshold defaults updated consistently.

The new temperature and humidity threshold defaults are properly documented and align with the code changes in temp_monitor.py and webhook_service.py.

Note: The static analysis warning about key ordering can be safely ignored—placing ALERT_TEMP_MIN_C before ALERT_TEMP_MAX_C is logical and improves readability.

temp_monitor.py (1)

120-121: LGTM! Default thresholds aligned with configuration.

The updated default values for temp_max_c (32.0°C) and humidity_min (20.0%) correctly match the new defaults in .env.example and webhook_service.py.

.github/workflows/ci.yml (2)

79-83: LGTM! Mandatory CLOUDFLARED_TOKEN validation properly implemented.

The validation ensures that the required secret is present before deployment proceeds, preventing deployment failures when the Cloudflare profile is enabled.


119-119: LGTM! Cloudflare profile correctly enabled.

The --profile cloudflare flag properly activates the Cloudflare tunnel service in the Docker Compose deployment, aligning with the mandatory CLOUDFLARED_TOKEN requirement.

webhook_service.py (1)

32-33: LGTM! AlertThresholds defaults updated consistently.

The updated default values for temp_max_c (32.0°C) and humidity_min (20.0%) correctly align with the changes in .env.example and temp_monitor.py.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 3, 2026

Caution

Docstrings generation - FAILED

No docstrings were generated.

- Increased maximum temperature alert threshold from 27°C to 32°C in README.md and CI workflow configuration.
- Decreased minimum humidity alert threshold from 30% to 20% in README.md and CI workflow configuration.
@fakebizprez
Copy link
Copy Markdown
Member Author

baz review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Jan 3, 2026

Skipped: This PR does not contain any of your configured labels: (greptile)

@fakebizprez fakebizprez merged commit 05228de into master Jan 3, 2026
5 checks passed
@fakebizprez fakebizprez deleted the hotfix/workflow branch January 3, 2026 20:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

baz approved bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant