• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hyperglass-community / hyperglass / 45126170724
89%

Build:
DEFAULT BRANCH: main
Ran 23 Nov 2026 06:45AM UTC
Jobs 2
Files 451
Run time 1min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

23 Nov 2026 06:44AM UTC coverage: 87.216% (+0.2%) from 87.053%
45126170724

push

github

web-flow
feat(api): add an optional rate limit for looking glass queries (#586)

* feat(api): add an optional rate limit for POST /api/query

Generalise the lookup quota into api/quota.py (take_quota: feature
name, limits, window) and use it for query_limit, off by default.
Queries answered from the cache count; requests rejected by
validation don't. Over the limit, HTTP 429 with Retry-After and
messages.rate_limited; Redis unreachable lets the query through.
Counted as reason rate_limited.

* fix(api): read params once per query

Each read of `_state.params` deserializes the configuration from
Redis. query() read it up to nine times, once after recording the
query as a success (the BackgroundTask's `params=`), so a Redis
failure there counted one query as both a success and an error. Read
it once near the top and reuse it, which also saves the query rate
limit an extra read.

Fixes #582

* feat(api): harden the query rate limit and pin its invariants

- Bound query_limit.window to 30 days, and give a counter found
  without an expiry one, so it can't block a client for good. Later
  requests still don't extend a counter's expiry.
- Export client_identity() from api/quota.py, the hashed identity
  take_quota() counts, for reuse by share creation (#559).
  client_address() and take_quota() accept web.client_ip from a
  caller that has it, so the guards don't read params again.
- Tests: a client over its limit leaves the global counter alone, a
  request over the global limit creates no client key, a second
  request keeps the expiry, the limit is checked before the cache is
  read, and the lookup 429 as clients get it through http_handler.
- Docs: each selected location is one query, so size client_limit
  for the number of locations; the query limit uses the client
  address.

* docs(api): say which rate counters the expiry repair covers

596 of 860 branches covered (69.3%)

Branch coverage included in aggregate %.

339 of 347 new or added lines in 12 files covered. (97.69%)

2 existing lines in 1 file now uncovered.

19079 of 21699 relevant lines covered (87.93%)

14.84 hits per line

Uncovered Changes

Lines Coverage ∆ File
4
91.49
hyperglass/api/quota.py
2
99.09
hyperglass/util/tests/test_query_limit.py
1
96.62
0.04% hyperglass/api/routes.py
1
99.49
-0.23% hyperglass/util/tests/test_metrics_endpoint.py

Coverage Regressions

Lines Coverage ∆ File
2
96.43
-1.31% hyperglass/api/auxiliary.py
Jobs
ID Job ID Ran Files Coverage
1 frontend - 45126170724.1 23 Nov 2026 06:45AM UTC 126
76.84
GitHub Action Run
2 backend - 45126170724.2 23 Nov 2026 06:48AM UTC 325
88.77
GitHub Action Run
Source Files on build 45126170724
  • Tree
  • List 451
  • Changed 12
  • Source Changed 11
  • Coverage Changed 10
Coverage ∆ File Lines Relevant Covered Missed Hits/Line Branch Hits Branch Misses
  • Back to Repo
  • Github Actions Build #45126170724
  • 232e3402 on github
  • Prev Build on main (#45121601908)
  • Next Build on main (#45126199074)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc