fix: initialize TEMP_LOG before conditional to prevent unbound variab…#7
Merged
Conversation
…le error When the log file doesn't exist (e.g., fresh installs before unattended-upgrades first runs), TEMP_LOG was only set inside the else branch. The Matrix notification section references TEMP_LOG unconditionally, causing 'TEMP_LOG: unbound variable' crash under set -euo pipefail. Initialize TEMP_LOG="" before the if/else block so grep calls against it safely fail with 2>/dev/null when the log file is absent.
Three issues fixed: 1. No-log-file case (fresh installs before unattended-upgrades first runs): Previously always showed yellow 'System Update Process Complete' with 'Log file not found' body regardless of available packages. Now checks AVAILABLE_UPDATES and sets status/body accordingly: - Updates available -> updates-available status, lists packages - Nothing available -> no-updates status, 'system is up to date' Both variants append 'No unattended-upgrades history yet (first run)'. 2. Title/status mismatch when security=clean but non-security packages exist: Previously title said 'System Update Check Complete / No updates available' while body said '10 non-security packages available' - contradictory. Added updates-available status promotion: when UPDATE_STATUS==no-updates but AVAILABLE_UPDATES>0, promotes to updates-available. 3. New 'updates-available' status case (orange, 16744272): Title: 'System Updates Available on <host>' Distinct from 'System Updates Applied' (green) and 'System Update Check Complete' (blue, nothing to do). 4. Matrix section falls back to PLAIN_SUMMARY when no log-parsed content available, ensuring consistent message body across all code paths.
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.
…le error
When the log file doesn't exist (e.g., fresh installs before unattended-upgrades first runs), TEMP_LOG was only set inside the else branch. The Matrix notification section references TEMP_LOG unconditionally, causing 'TEMP_LOG: unbound variable' crash under set -euo pipefail.
Initialize TEMP_LOG="" before the if/else block so grep calls against it safely fail with 2>/dev/null when the log file is absent.
Description
Type of Change
Related Issues
Fixes #
Closes #
Related to #
Changes Made
Testing Performed
Manual Testing
Test Commands Run
# List commands you ran to testTest Results
Checklist
Screenshots/Logs
Additional Context
Deployment Notes