Skip to content

fix: handle unknown weather codes#1796

Open
juliogc wants to merge 4 commits into
HyDE-Project:devfrom
juliogc:fix/weather-unknown-codes
Open

fix: handle unknown weather codes#1796
juliogc wants to merge 4 commits into
HyDE-Project:devfrom
juliogc:fix/weather-unknown-codes

Conversation

@juliogc

@juliogc juliogc commented Jun 21, 2026

Copy link
Copy Markdown

Pull Request

Description

Fixes weather applet crashes when wttr.in returns an unmapped weather code or when the wttr.in request/JSON response is unavailable.

The crash observed locally was:

KeyError: '149'

This PR maps code 149 to the existing cloudy/foggy icon group, falls back to a generic cloudy icon for future unknown codes, and returns a valid Waybar JSON error object when weather data cannot be fetched or parsed.

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 (non-breaking change; modified files are limited to the documentations)
  • Technical debt (a code change that does not fix a bug or add a feature but makes something clearer for devs)
  • Other (provide details below)

Checklist

  • I have read the CONTRIBUTING document.
  • My code follows the code style of this project.
  • My commit message follows the commit guidelines.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added a changelog entry.
  • I have added necessary comments/documentation to my code.
  • I have added tests to cover my changes.
  • I have tested my code locally and it works as expected.
  • All new and existing tests passed.

Screenshots

Not applicable.

Summary by CodeRabbit

  • Bug Fixes

    • Weather applet now handles unknown weather codes and unavailable weather service responses without crashing.
    • Missing or incomplete weather data now shows a clear “Weather unavailable” message instead of failing.
    • Windows with the Ghidra project manager title now open as floating windows for easier use.
  • Documentation

    • Updated the changelog to reflect the weather applet stability fix.

@coderabbitai

coderabbitai Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5d419b6a-44a5-4c36-8d21-0d7b30603024

📥 Commits

Reviewing files that changed from the base of the PR and between 39ead6a and 0857990.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • Configs/.config/hypr/windowrules.conf
  • Configs/.local/lib/hyde/weather.py
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
  • Configs/.config/hypr/windowrules.conf

📝 Walkthrough

Walkthrough

This PR improves weather applet error handling by adding a safe fallback icon lookup and centralizing wttr.in request/validation logic with graceful failure handling, documents this fix in the changelog, and adds a Hyprland window rule to float Ghidra's "NO ACTIVE PROJECT" dialog.

Changes

Weather Applet Resilience

Layer / File(s) Summary
Icon fallback
Configs/.local/lib/hyde/weather.py
Adds weather code "149" to the cloud icon set and changes get_weather_icon() to use dict.get with a default icon instead of direct indexing.
Fetch fallback
Configs/.local/lib/hyde/weather.py
Adds get_weather_data() to fetch and validate wttr.in responses (returning None on errors or missing data) and print_weather_unavailable(); main() now uses these helpers and exits with status 0 when weather data is unavailable.
Changelog entry
CHANGELOG.md
Documents the weather applet crash-prevention fix under v26.4.5 Fixed.

Hyprland Window Rule

Layer / File(s) Summary
Ghidra window rule
Configs/.config/hypr/windowrules.conf
Adds a windowrule to float windows with initial_title matching "Ghidra: NO ACTIVE PROJECT".

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

A cloud icon now never goes astray,
wttr.in fails? We hop away! 🐰
No crash, no fuss, just a calm little sign,
and Ghidra floats free, its window aligned.
Carrots for code that handles it right~ 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main bug fix: handling unknown weather codes in the weather applet.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

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

@juliogc
juliogc marked this pull request as ready for review July 3, 2026 22:30

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@Configs/.local/lib/hyde/weather.py`:
- Around line 328-330: The compact one-line try/except in get_weather_data is
triggering Ruff E701/E702, so expand it into standard բազմ-line Python syntax
with the try block, request/json parsing, and separate except clause returning
None. Also check the other flagged one-liner in this module (the same lint issue
at the referenced locations) and rewrite it in multiline form so CI linting
passes.
- Around line 328-330: The weather fetch path still allows invalid wttr.in error
payloads to reach downstream indexing. Update get_weather_data() to capture
non-2xx responses before parsing JSON by calling raise_for_status() on the
response and handling HTTPError alongside the existing request/JSON exceptions,
and make main() defensive when reading weather["current_condition"][0] by
checking that the key exists and has at least one entry before indexing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7b4dcffd-452a-4fbe-828a-ab96bf2e7057

📥 Commits

Reviewing files that changed from the base of the PR and between 1ca4d45 and 1e77738.

📒 Files selected for processing (2)
  • CHANGELOG.md
  • Configs/.local/lib/hyde/weather.py

Comment thread Configs/.local/lib/hyde/weather.py Outdated
@juliogc
juliogc force-pushed the fix/weather-unknown-codes branch from 1e77738 to 39a73a1 Compare July 5, 2026 01:48

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
Configs/.config/hyde/wallbash/scripts/wayle-theme.sh (1)

8-21: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Only dcol_pry1 is guarded; the other 9 dcol_* vars used below are not.

Line 8 exits early if dcol_pry1 is empty, but dcol_pry2, dcol_pry3, dcol_txt1, dcol_3xa6, dcol_1xa7, dcol_1xa8, dcol_1xa6, dcol_2xa7, and dcol_3xa7 are used unguarded (flagged by shellcheck SC2154 as referenced-but-not-assigned). If any of these are unset for a given wallpaper/theme, wayle config set ... "#" would silently write an invalid/empty color since stderr is discarded with 2>/dev/null.

♻️ Suggested guard + shellcheck annotations
+# shellcheck disable=SC2154  # dcol_* vars are exported by color.set.sh via `set -a; source "$dcol_file"`
 command -v wayle >/dev/null 2>&1 || exit 0
 pgrep -x wayle >/dev/null 2>&1 || exit 0
-[[ -z "$dcol_pry1" ]] && exit 0
+for v in dcol_pry1 dcol_pry2 dcol_pry3 dcol_txt1 dcol_3xa6 dcol_1xa7 dcol_1xa8 dcol_1xa6 dcol_2xa7 dcol_3xa7; do
+  [[ -z "${!v}" ]] && exit 0
+done
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Configs/.config/hyde/wallbash/scripts/wayle-theme.sh` around lines 8 - 21,
The wayle theme update in wayle-theme.sh only checks dcol_pry1, but the other
dcol_* variables used by the palette writes can still be unset and produce
invalid empty colors. Update the guard logic around the wayle config set calls
so all referenced palette inputs in this block are validated before use, or skip
each assignment when its source variable is empty, and add the appropriate
shellcheck handling near this section if these values are intentionally provided
by the sourcing context.

Source: Linters/SAST tools

Configs/.config/hypr/windowrules.conf (1)

95-95: 🎯 Functional Correctness | 🔵 Trivial | 💤 Low value

Anchor the title regex for consistency.

Unlike the sibling rule on Line 94 (^(Image Editor)$), this pattern omits the trailing $, so it would also match titles with extra trailing text.

🩹 Suggested fix
-windowrule = float true, match:initial_title ^(Ghidra: NO ACTIVE PROJECT) `#Ghidra` Project manager
+windowrule = float true, match:initial_title ^(Ghidra: NO ACTIVE PROJECT)$ `#Ghidra` Project manager
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Configs/.config/hypr/windowrules.conf` at line 95, The windowrule for the
Ghidra project manager uses an inconsistent title regex in the hypr window rules
config: the pattern in the float rule matches extra trailing text because it is
not fully anchored. Update the `windowrule = float true, match:initial_title
...` entry to use a fully anchored regex like the sibling rule, keeping the
`initial_title` match and adding the missing end anchor so only the exact window
title is matched.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@Configs/.config/hyde/wallbash/scripts/wayle-theme.sh`:
- Around line 8-21: The wayle theme update in wayle-theme.sh only checks
dcol_pry1, but the other dcol_* variables used by the palette writes can still
be unset and produce invalid empty colors. Update the guard logic around the
wayle config set calls so all referenced palette inputs in this block are
validated before use, or skip each assignment when its source variable is empty,
and add the appropriate shellcheck handling near this section if these values
are intentionally provided by the sourcing context.

In `@Configs/.config/hypr/windowrules.conf`:
- Line 95: The windowrule for the Ghidra project manager uses an inconsistent
title regex in the hypr window rules config: the pattern in the float rule
matches extra trailing text because it is not fully anchored. Update the
`windowrule = float true, match:initial_title ...` entry to use a fully anchored
regex like the sibling rule, keeping the `initial_title` match and adding the
missing end anchor so only the exact window title is matched.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 63b895a6-96e9-4714-b58b-c648535857c0

📥 Commits

Reviewing files that changed from the base of the PR and between 1e77738 and 39a73a1.

📒 Files selected for processing (17)
  • CHANGELOG.md
  • CONTRIBUTORS.md
  • Configs/.config/hyde/wallbash/always/wayle.dcol
  • Configs/.config/hyde/wallbash/scripts/wayle-theme.sh
  • Configs/.config/hypr/windowrules.conf
  • Configs/.local/bin/hyde-shell
  • Configs/.local/lib/hyde/globalcontrol.sh
  • Configs/.local/lib/hyde/pm/zypper.py
  • Configs/.local/lib/hyde/session.py
  • Configs/.local/lib/hyde/volumecontrol.sh
  • Configs/.local/lib/hyde/wallpaper.sh
  • Configs/.local/lib/hyde/weather.py
  • Configs/.local/share/hypr/startup.conf
  • Configs/.local/share/wallbash/theme/waybar.dcol
  • Scripts/pkg_extra.lst
  • Source/docs/README.zh.md
  • Wiki
💤 Files with no reviewable changes (1)
  • Wiki
✅ Files skipped from review due to trivial changes (4)
  • CONTRIBUTORS.md
  • Configs/.local/lib/hyde/volumecontrol.sh
  • CHANGELOG.md
  • Configs/.local/lib/hyde/pm/zypper.py

@juliogc
juliogc force-pushed the fix/weather-unknown-codes branch from 39a73a1 to 39ead6a Compare July 5, 2026 02:12
Yuzuru10 and others added 4 commits July 4, 2026 23:14
* made ghidra project manager to float

* Change Ghidra window rule to float true

---------

Co-authored-by: Khing <53417443+kRHYME7@users.noreply.github.com>
- Add wayle to session.py known bars for clean session management
- Add wallbash hook (wayle.dcol) to sync wallpaper colors with wayle
- Make waybar.dcol conditional: skip waybar update when not running
Uses dcol_* environment variables passed by wallbash's fn_wallbash
to set wayle palette colors on every wallpaper/theme change.
Files placed in .config/hyde/wallbash/ (non-core component).
@juliogc
juliogc force-pushed the fix/weather-unknown-codes branch from 39ead6a to 0857990 Compare July 5, 2026 02:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants