Skip to content

fix: add retry logic for API timeout errors#1

Open
beaglemoo wants to merge 7 commits into
mainfrom
fix/api-timeout-retry
Open

fix: add retry logic for API timeout errors#1
beaglemoo wants to merge 7 commits into
mainfrom
fix/api-timeout-retry

Conversation

@beaglemoo
Copy link
Copy Markdown
Owner

Summary

  • OAuth token request and data fetch requests had no retry handling for timeouts, causing complete run failures when the GOV.UK Fuel Finder API was temporarily slow
  • Both the 04:00 and 08:00 BST runs on 2026-03-29 failed due to httpx.ReadTimeout during the clock change
  • Adds up to 3 retries with 5/15/30s backoff for ReadTimeout, ConnectTimeout, and PoolTimeout in both auth.py and client.py

Test plan

  • Deployed to ansible box and triggered manual run - completed successfully
  • Next scheduled run (12:00 BST) will validate timer-triggered execution

- Ghost publisher generates HTML with regional price tables and UK top 20
  cheapest for E10 and diesel, auto-updates sillymoo.dev/uk-fuel-prices
- Grafana dashboard with stat panels, price table, time series trends,
  brand and region comparison charts with template variables
- Updated config to support Ghost page_id for direct page updates
- Add extract_location() to parse town/city from station trading names
- Rewrite Ghost page with client-side search/filter covering all ~6,300 stations
- Embed station data as JSON, render results dynamically with JavaScript
- Search matches on station name, brand, and extracted location
- Sort by unleaded, diesel, super, or name with clickable controls
- Paginated results (100 at a time) for performance
- Keep regional highlights and Top 20 as static sections below search
- Fix: pass page_id to Ghost API, use internal blog URL for admin access
Ghost's codeinjection_foot has a ~65KB limit which can't hold the
~655KB station JSON. Instead, SCP the JSON to Ghost's content/files
directory and fetch it client-side. Also removes regional highlight
sections (redundant with search), adds __main__.py for python -m
support, and adds ghost.host config for SSH uploads.
Adds JSON-LD Dataset markup to the fuel prices page code injection
header, telling Google this is a dataset based on GOV.UK government
data with regular updates.
Show top 10 for Unleaded, Diesel, Super Unleaded, and Premium Diesel
instead of just top 20 for Unleaded and Diesel.
- Station names link to Google Maps search (Top 10 tables + search results)
- Brand filter buttons (Shell, BP, Esso, Tesco, etc.)
- Price staleness indicator with coloured dots and age labels
- Search result summary stats (avg, cheapest, range)
- Enhanced Dataset schema with keywords, spatialCoverage, distribution
- Dynamic FAQ schema with live cheapest price data
- Keyword-rich static paragraph for Google crawlability
- Mobile polish: iOS zoom fix, 44px tap targets, scrollable brand bar
The OAuth token request and data fetch had no retry handling for
timeouts, causing complete run failures when the GOV.UK API was
temporarily slow (e.g. during BST clock change). Adds up to 3
retries with 5/15/30s backoff delays for ReadTimeout, ConnectTimeout,
and PoolTimeout errors.
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.

1 participant