Skip to content

Hypixel key rate limiter + deploy volume-resolution fix - #21

Merged
Pankraz01 merged 5 commits into
mainfrom
deploy/merge-main-ratelimiter
Sep 9, 2026
Merged

Pankraz01 merged 5 commits into
mainfrom
deploy/merge-main-ratelimiter

Conversation

@Pankraz01

Copy link
Copy Markdown
Contributor

Brings the currently deployed production state back onto main.

What is in here

  • feat(marketguard): Hypixel API key quota, 300 requests / 5 min. A process-wide rolling-window limiter in front of HypixelPlayerClient, the only client that sends an API-Key header. Requests are counted on attempt, including ones that later time out, because those may still have reached Hypixel and consumed quota. This code was found uncommitted on the production server and existed in no branch — recovering it is the main point of this PR.
  • fix(deploy): scope named-volume lookup to this Compose project. resolve_named_volumes() matched any host volume ending in the logical suffix, so a second Compose project owning proxy_caddy_data made every deployment abort with "Ambiguous Docker volumes". Its own error text suggested COMPOSE_PROJECT_NAME, which the script never read, and deleting "stale" volumes, which on this host would have wiped the master reverse proxy's TLS certificates. The project name is now resolved the way Compose resolves it, and <project>_<logical> wins.
  • Two commits that were only on agent/document-optional-player-profile (player API test expectations, optional profile docs).
  • origin/main merged in, so the MarketGuard snapshot-refresh fix, refresher.py and the cryptography CVE bump are included.

Verification

  • 124 tests pass locally, including the new rolling-window test.
  • Deployed to production and verified: all six containers healthy, /api/v1/ready returns status: ok, /login, /market/, /api/v2/lowestbin, /api/v1/bazaar and /openapi.json all 200.
  • Confirmed in the running container that max_requests=300 / window_seconds=300 are live.

One merge conflict was resolved in tests/test_marketguard_api.py: same call, different kwarg order and dummy key. Kept test-hypixel-key, the convention used ~10 times elsewhere in the file, over main's one-off test-key. Functionally identical, that test does not assert the key value.

🤖 Generated with Claude Code

Pankraz01 and others added 5 commits August 1, 2026 13:17
Adds a process-wide rolling-window rate limiter in front of the Hypixel
client. Requests are counted on attempt (including ones that later time
out), because those may still have reached Hypixel and consumed quota.

Recovered from an uncommitted working tree on the production server.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…elimiter

# Conflicts:
#	tests/test_marketguard_api.py
resolve_named_volumes() matched any host volume ending in the logical
suffix, so a second Compose project owning e.g. proxy_caddy_data made the
lookup ambiguous and aborted every deployment. COMPOSE_PROJECT_NAME was
named in the error text but never actually read.

Now the project name is resolved the way Compose resolves it (env var,
env file, compose `name:`, then directory name) and a candidate matching
`<project>_<logical>` wins. Unrelated stacks on the same host no longer
block a deploy, and no volume has to be deleted to unblock one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Pankraz01
Pankraz01 merged commit 8b4169e into main Sep 9, 2026
1 check passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 5a87c594af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

if not api_key:
raise HypixelUpstreamError("Hypixel player API is not configured.")

await _HYPIXEL_KEY_RATE_LIMITER.acquire()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate limiter exhaustion from player lookups

Once /api/v1/players reaches 300 authenticated calls in the rolling window, this acquisition raises HypixelRateLimitError, but PlayerService.get_players() catches its HypixelUpstreamError superclass at player_service.py:70-72 and converts the affected lookups into status: "unavailable". Consequently the route's dedicated rate-limit handler at routes.py:322-329 is never reached: callers receive HTTP 200 without Retry-After, and the unavailable result is cached as a successful response. Re-raise HypixelRateLimitError before the generic upstream catch so exhaustion is surfaced as the documented temporary failure.

AGENTS.md reference: AGENTS.md:L74-L80

Useful? React with 👍 / 👎.

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