we-promise/sure · warning · Provider::AlphaVantage::RateLimitError
parsed["Note"]
Error message
parsed["Note"]
What it means
check_api_error! raises Provider::AlphaVantage::RateLimitError with the raw value of the response's 'Note' key. Alpha Vantage signals upstream rate limiting with HTTP 200 plus a JSON 'Note' field (e.g. call-frequency messages) rather than a 429 status; the provider detects this and converts it to a typed rate-limit error after warning to the log.
Source
Thrown at app/models/provider/alpha_vantage.rb:326
when "STO" then "SEK"
when "CPH" then "DKK"
when "OSL" then "NOK"
else "USD"
end
Rails.cache.write(cache_key, currency, expires_in: 24.hours)
currency
end
# Checks for Alpha Vantage-specific error responses.
# Alpha Vantage returns errors as JSON keys rather than HTTP status codes.
def check_api_error!(parsed)
return unless parsed.is_a?(Hash)
# Rate limit: Alpha Vantage returns a "Note" key when rate-limited
if parsed["Note"].present?
Rails.logger.warn("AlphaVantage rate limit: #{parsed["Note"]}")
raise RateLimitError, parsed["Note"]
end
# General info/limit messages
if parsed["Information"].present?
Rails.logger.warn("AlphaVantage info: #{parsed["Information"]}")
raise RateLimitError, parsed["Information"]
end
# Explicit error messages for invalid parameters
if parsed["Error Message"].present?
raise Error, "API error: #{parsed["Error Message"]}"
end
end
end
View on GitHub (pinned to e69894adb9)
Solutions
- Back off and retry with exponential delay (upstream limits are time-windowed), or reschedule to the next day.
- Upgrade the Alpha Vantage plan or lower request frequency (raise MIN_REQUEST_INTERVAL/batch more).
- Ensure only one environment uses the key; duplicate consumers multiply upstream counts.
- Rescue Provider::AlphaVantage::RateLimitError and surface it in provider usage/health UI instead of failing the job.
Example fix
# before provider.fetch_security_prices(symbol: s, start_date: from, end_date: to) # after attempts = 0 begin provider.fetch_security_prices(symbol: s, start_date: from, end_date: to) rescue Provider::AlphaVantage::RateLimitError attempts += 1 raise if attempts > 3 sleep(60 * attempts) && retry end
Defensive patterns
Strategy: retry
Try / catch
begin provider.fetch_security_prices(symbol: s, start_date: a, end_date: b) rescue Provider::AlphaVantage::RateLimitError => e sleep(60 * (attempt += 1)) retry if attempt < 3 raise end
Prevention
- Honor the local MIN_REQUEST_INTERVAL throttle; do not parallelize AV calls.
- Use a dedicated API key per environment so counts are predictable.
- Treat 'Note' responses as upstream 429s: back off, then retry with jitter.
When it happens
Trigger: Exceeding Alpha Vantage's upstream per-minute/per-day call frequency for your API key tier — distinct from the local daily counter; bursts of requests after the interval throttle lapses; shared key used by another app.
Common situations: Free-tier key hitting the upstream 25/day or 5/min limit while the local counter is lower; key used in multiple environments; clock skew between local throttle and upstream window.
Related errors
- Alpha Vantage daily request limit reached (#{max_requests_pe
- No data returned from search endpoint
- No metadata returned for symbol #{av_symbol}
- No prices found for security #{symbol} on date #{date}
- No time series data returned for symbol #{av_symbol}
AI-assisted analysis of we-promise/sure@e69894adb9 (2026-08-21).
Data as JSON: /api/errors/8e8ecc2a93ceaa2a.
Report an issue: GitHub.