Skip to content

fix: initialize TEMP_LOG before conditional to prevent unbound variab…#7

Merged
ChiefGyk3D merged 2 commits into
mainfrom
fix/temp-log-unbound-variable
Mar 20, 2026
Merged

fix: initialize TEMP_LOG before conditional to prevent unbound variab…#7
ChiefGyk3D merged 2 commits into
mainfrom
fix/temp-log-unbound-variable

Conversation

@ChiefGyk3D

Copy link
Copy Markdown
Owner

…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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Security fix

Related Issues

Fixes #
Closes #
Related to #

Changes Made

Testing Performed

Manual Testing

  • Tested on Debian/Ubuntu
  • Tested on RHEL/Rocky/Fedora
  • Tested with LOCAL secrets mode
  • Tested with DOPPLER secrets mode
  • Verified notifications work (Discord/Matrix/Teams/Slack)

Test Commands Run

# List commands you ran to test

Test Results

# Paste relevant test output

Checklist

  • My code follows the project's style guidelines
  • I have performed a self-review of my code
  • I have commented my code where necessary
  • I have updated the documentation accordingly
  • My changes generate no new warnings
  • I have tested my changes on the target platforms
  • All shell scripts pass shellcheck
  • All tests pass successfully

Screenshots/Logs

Additional Context

Deployment Notes

  • Requires configuration changes
  • Requires service restart
  • Breaking changes require migration steps
  • Update to README or documentation needed

…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.
@ChiefGyk3D ChiefGyk3D self-assigned this Mar 20, 2026
@ChiefGyk3D ChiefGyk3D added the bug Something isn't working label Mar 20, 2026
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.
@ChiefGyk3D
ChiefGyk3D merged commit 30870f5 into main Mar 20, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant