Skip to content

nvx: name the HTTP statuses of the GitHub release client - #2247

Merged
Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2245-github-http-statuses
Nov 27, 2026
Merged

Pedro Henrique Penna (ppenna) merged 1 commit into
devfrom
agents/issue-2245-github-http-statuses

Conversation

@ppenna

Copy link
Copy Markdown
Contributor

Fixes #2245

What does this pull request change?

The GitHub release client of nvx download, nvx/src/host/cli/download/github.rs, names the HTTP statuses that it acts on once, in module-private constants whose doc comments cite RFC 9110 section 15:

  • SUCCESSFUL: Range<u16> = 200..300 replaces (200..300) in GitHub::download and the pattern 200..=299 in GitHub::json, which now matches status if SUCCESSFUL.contains(&status) as its first arm, as before.
  • REDIRECTION: Range<u16> = 300..400 replaces (300..400) in GitHub::get and read_response.
  • MIN_STATUS: u16 = 100 replaces the bound in status_code.
  • UNAUTHORIZED, FORBIDDEN, and NOT_FOUND replace 401, 403, and 404 in GitHub::json and hint.

The values, the order of the match arms, and every message are unchanged. Start with the constants after HEADERS_NAME. Nothing else changes; the issue lists no follow-ups.

Why is this change needed?

The client spelled the same status class in two forms (200..300 and 200..=299), repeated the 3xx range and 404 across functions, and gave no reason for the bounds. One name per class states what each check means and keeps the four call sites from drifting apart. Matching constants as patterns compiles to the same comparisons as the literals, so behavior is unchanged. A helper function such as is_redirect was rejected: it adds an indirection for a one-line range check, and the ranges read as directly as the class names.

How was this change validated?

Checks and results:

  • Base 2e302197d90, Windows: cargo test --locked --features cli --manifest-path nvx/Cargo.toml --lib -- host::cli::download::github: 13 passed. Same command at head a9ab3996fce: 13 passed, tests unchanged.
  • python scripts\local_gates.py --base origin/dev --run on this Windows workstation (local): test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-msrv, nvx-cli all passed (nvx-cli: 2326 tests OK, skipped=92; 84 tests OK, skipped=11). Release nvx was not built there, so the tests that run nvx skipped on Windows; they ran on Linux below.
  • python3 scripts/local_gates.py --base origin/dev --run in WSL 2 (local fallback, clone at a9ab3996fce): test-changes, markdown-links, test-layout, nvx-format, nvx-lint, nvx-test, nvx-doc, nvx-public-api, nvx-msrv, nvx-macos, nvx-guest-binaries-lint, nvx-guest-binaries-build passed. nvx-cli first failed in its pip install step because the WSL system Python is externally managed (PEP 668); rerun whole with --only nvx-cli in a temporary --system-site-packages venv (PyYAML 6.0.3 already satisfied, nothing installed) and release nvx built: passed (2326 tests OK, skipped=41; 84 tests OK).
  • A code-review pass of the diff found no issues.

Backend, host OS, host type, and guest: no runtime path changes; no microVM was booted. All configured kvm profiles were unreachable (azure-intel-kvm-1 to -5 and -7, azure-amd-kvm-1 to -4), so Linux gates ran in this workstation's WSL 2 rather than on a configured host.

Left to CI: the microVM scenarios that the selector lists for kvm, mshv, and whp (they do not exercise nvx download's GitHub client), and mshv entirely.

Checklist

  • Tests cover the new or fixed behavior, in the layout that
    python3 scripts/check_test_layout.py checks.
  • python3 scripts/check_test_changes.py --base origin/dev lists no change
    to an existing test, or a Changes to existing tests section below
    explains each one.
  • The documentation that the change affects is updated, including
    .github/copilot-instructions.md and the skills when a convention or
    workflow changes.
  • A change to the public API of nvx updates nvx/public-api/ with
    python3 scripts/public_api.py --update.
  • Snapshots, protocols, and on-disk formats stay compatible, or the
    description says how the change versions or migrates them.

The GitHub release client of nvx download spelled the HTTP statuses
that it acts on as bare literals, and the same class in different
forms: the success check was !(200..300).contains(..) in download but
the range pattern 200..=299 in json, the redirect check (300..400)
appeared twice, the least valid status was a bare 100, and 404 was
repeated in json and hint next to 401 and 403.

Name them once, in module-private constants whose doc comments cite
RFC 9110 section 15: MIN_STATUS, SUCCESSFUL, REDIRECTION,
UNAUTHORIZED, FORBIDDEN, and NOT_FOUND. json matches a successful
status with a guard first, as 200..=299 did, so the arms keep their
order. The values, requests, redirects, errors, and hints are
unchanged.

Tests: the 13 host::cli::download::github unit tests, which cover
redirects, response parsing, error responses, and hints, pass
unchanged at the base 2e30219 and with this change on Windows.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 27, 2026 05:33

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The HTTP status constant refactor has no active review issues.

No open issues 🎉

What changed in this PR

Makes HTTP status checks in nvx download’s GitHub release client consistent and self-documenting, addressing #2245 without changing behavior.

Changes:

  • Adds module-private status constants and ranges with RFC 9110 references.
  • Replaces literals in success checks, redirect handling, status parsing, and error hints, preserving match order and messages.
File Description
nvx/​src/​host/​cli/​download/​github.rs Defines documented HTTP status constants and reuses them throughout the release client.

Review effort: Balanced

@ppenna
Pedro Henrique Penna (ppenna) added this pull request to the merge queue Nov 27, 2026
Merged via the queue into dev with commit 15daf5c Nov 27, 2026
56 checks passed
@ppenna
Pedro Henrique Penna (ppenna) deleted the agents/issue-2245-github-http-statuses branch November 27, 2026 07:38
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.

nvx: name the HTTP statuses of the GitHub release client

2 participants