fix(dashboard): reconstruct GDACS source links for reports without link field#54
Merged
Merged
Conversation
…nk field
Two GDACS reports in production had empty source_link URLs, causing the
dashboard to redirect back to itself when clicked:
- 20251221-XX-DR Drought Green (degenerate RSS — only alertlevel/severity/
population/episodeid in raw_fields; no link/eventid/eventtype)
- 20260702-PT-WF Forest Fire Aveiro (newer RSS shape — URL lives in
raw_fields.url as a dict {geometry, report, details}, not in a link field)
Root cause: generate_dashboard_data.py:494 read only rf.get('link', '').
Reports without a 'link' field produced url='' which the frontend rendered
as href='' (browser navigates to the current page).
Fix:
- _resolve_gdacs_link(raw_fields, source_id, incident_type) tries three
sources in order: (1) rf['link'] (43/45 reports), (2) rf['url']['report']
dict sub-key (Portugal case), (3) construct from source_id + episodeid +
eventtype code derived from incident_type via _GDACS_EVENTTYPE_CODES
reverse map (drought case — confirmed opens the correct GDACS page).
- app.js safety net: render a disabled <span> (⊘) instead of <a href=''>
when L.url is empty, so any future empty-URL case can't redirect to self.
Tests: 5 new TestResolveGdacsLink covering all three fallback paths plus
the empty case. 256 tests pass, pyright 0 errors, ruff clean (4 pre-existing
C901).
nullhack
added a commit
that referenced
this pull request
Jul 23, 2026
Regenerated dashboard JSON with _resolve_gdacs_link fallback chain (rf.link → rf.url.report → constructed from source_id+episodeid+eventtype). Fixes empty-URL source links that redirected back to the dashboard.
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.
Problem
Two GDACS incidents had empty
source_linkURLs in the dashboard JSON, causing the source-record links to redirect back to the dashboard itself when clicked:linkwas missing20251221-XX-DRDrought Greenc892ccdaf15e{alertlevel, severity, population, episodeid}in raw_fields20260702-PT-WFForest Fire Aveirof3e5d132af05raw_fields.urlas a dict{geometry, report, details}Root cause
scripts/generate_dashboard_data.py:494read onlyrf.get('link', ''). Reports without alinkfield producedurl='', which the frontend (app.js:820) rendered ashref=""— the browser treats this as a link to the current page.Fix
1.
_resolve_gdacs_link(raw_fields, source_id, incident_type)— tries three sources in order:rf['link'](43/45 GDACS reports — the normal case)rf['url']['report']dict sub-key (the Portugal newer-RSS case)source_id+episodeid+ eventtype code (derived fromincident_typevia_GDACS_EVENTTYPE_CODESreverse map) — the degenerate drought case. Verified manually: the constructed URLhttps://www.gdacs.org/report.aspx?eventid=1018332&episodeid=14&eventtype=DRopens the correct GDACS page ("Overall Orange Drought for Europe-2026").2.
app.jssafety net — whenL.urlis empty, render a disabled<span>(⊘ icon) instead of<a href="">, so any future empty-URL case can't redirect to self.Tests
5 new
TestResolveGdacsLinkcovering all three fallback paths + the empty case. 256 tests pass, pyright 0 errors, ruff clean (4 pre-existing C901).