Skip to content

fix(cloud): bound pending login sessions and require enabled cloud#75

Merged
hyperb1iss merged 2 commits into
mainfrom
codex/fix-unbounded-cloud-login-sessions
May 19, 2026
Merged

fix(cloud): bound pending login sessions and require enabled cloud#75
hyperb1iss merged 2 commits into
mainfrom
codex/fix-unbounded-cloud-login-sessions

Conversation

@hyperb1iss
Copy link
Copy Markdown
Owner

Motivation

  • The cloud device-login flow stored pending DeviceAuthorizationSessions in an unbounded in-memory map and never pruned them unless a client polled, enabling unbounded memory growth and an availability DoS.
  • start_login did not check whether cloud was enabled in the daemon config, so the endpoint could be used on deployments where cloud should be disabled.

Description

  • Added a hard cap MAX_PENDING_CLOUD_LOGIN_SESSIONS = 128 and admission checking in crates/hypercolor-daemon/src/api/cloud.rs to refuse new starts when the pending-session limit is reached.
  • Require cloud.enabled for start_login and return 409 Conflict when cloud is disabled.
  • Ensure expired sessions are pruned before admission and return 429 Rate Limited when the pending limit is reached, and insert the new session only after these checks.
  • Added regression tests in crates/hypercolor-daemon/tests/cloud_api_tests.rs named cloud_login_start_rejects_when_cloud_disabled and cloud_login_start_rejects_when_pending_session_limit_reached to cover the new behaviors.

Testing

  • Ran cargo fmt --all, which completed successfully.
  • Added and executed focused tests for the new behavior; cloud_login_start_rejects_when_cloud_disabled and cloud_login_start_rejects_when_pending_session_limit_reached were added to the cloud feature test suite.
  • Test runs were started (cargo test -p hypercolor-daemon --features cloud ...) but a full test build did not finish within the execution window due to long compilation times; no unexpected failures were observed during edit/compile iterations.

Codex Task

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

Warning

Rate limit exceeded

@hyperb1iss has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 36 minutes and 5 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4cbf7ab2-fc5b-4b1e-9c07-f8b89e3fa735

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce1abe and cb0cb9a.

📒 Files selected for processing (2)
  • crates/hypercolor-daemon/src/api/cloud.rs
  • crates/hypercolor-daemon/tests/cloud_api_tests.rs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/fix-unbounded-cloud-login-sessions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

hyperb1iss and others added 2 commits May 19, 2026 01:47
The two new start_login tests built a full daemon AppState via the
process-global data-dir override, racing other parallel tests on the
shared asset index. Each test now builds state with an explicit,
owned temp data dir, so no global state is shared.
@hyperb1iss hyperb1iss force-pushed the codex/fix-unbounded-cloud-login-sessions branch from 0719de1 to cb0cb9a Compare May 19, 2026 08:57
@hyperb1iss hyperb1iss merged commit cdffd2b into main May 19, 2026
4 of 5 checks passed
@hyperb1iss hyperb1iss deleted the codex/fix-unbounded-cloud-login-sessions branch May 19, 2026 08:58
hyperb1iss added a commit that referenced this pull request May 19, 2026
* test(cloud): re-enable cloud in regressed login start/poll tests

PR #75 added a gate that rejects `POST /cloud/login/start` with 409
when cloud is disabled. Two login tests built their `AppState`
through `cloud_test_state`, which hard-codes `cloud.enabled = false`,
so after #75 they hit that gate. The start test asserted 201
and got 409; the poll test then panicked on the `login_id`
missing from the 409 error body.

The `cloud` feature carries no CI coverage, so the regression reached
main unnoticed. Point both tests at `cloud_test_state_with_cloud`
with cloud enabled and drop the now-unused `cloud_test_state`
wrapper.

Co-Authored-By: Nova (Claude Opus 4.7) <noreply@anthropic.com>

* style(cloud): use larger Duration units in cloud socket

Clippy's `duration_suboptimal_units` flags `Duration::from_secs`
calls whose values land exactly on a larger unit. `cloud_socket.rs`
built a 3600-second heartbeat ceiling and a 60-second reconnect
cap that read more clearly as one hour and one minute.

Switch to `Duration::from_hours(1)` and `Duration::from_mins(1)`,
and update the matching `cloud_socket_tests.rs` assertions. The
durations are unchanged. These lints had accumulated because the
`cloud` feature has no CI lint pass.

Co-Authored-By: Nova (Claude Opus 4.7) <noreply@anthropic.com>

---------

Co-authored-by: Nova (Claude Opus 4.7) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant