Skip to content

feat: Shared HTTP Client#9

Merged
math280h merged 1 commit intomainfrom
chore/shared-http-client
Feb 26, 2026
Merged

feat: Shared HTTP Client#9
math280h merged 1 commit intomainfrom
chore/shared-http-client

Conversation

@math280h
Copy link
Owner

No description provided.

@math280h math280h self-assigned this Feb 26, 2026
Copilot AI review requested due to automatic review settings February 26, 2026 02:34
@github-actions
Copy link

Coverage

Coverage Report

Metric Value
Total lines 5615
Covered lines 4756
Missed lines 859
Coverage 84.70%
Tests passed 166
Tests failed 0
Tests ignored 0
Coverage command exit 0
Per-file coverage (top 40 by missed lines)
File Stmts Miss Cover Missing
/home/runner/work/safe-pkgs/safe-pkgs/src/service.rs 342 137 59.94% 40, 41, 42, 43, 44, 45, 89, 90, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/custom_rules.rs 194 119 38.66% 41, 70, 71, 80, 81, 82, 83, 96, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/config/custom_rules.rs 155 67 56.77% 132, 159, 165, 172, 175, 194, 195, 197, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/staleness/src/lib.rs 210 55 73.81% 63, 64, 65, 66, 67, 68, 69, 70, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/policy_snapshot.rs 209 48 77.03% 120, 146, 147, 148, 149, 150, 151, 152, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/main.rs 93 44 52.69% 43, 115, 116, 118, 119, 120, 121, 122, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/core/src/lib.rs 347 37 89.34% 82, 83, 84, 100, 101, 102, 118, 119, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/mcp/server.rs 97 32 67.01% 104, 105, 106, 128, 129, 131, 132, 133, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/checks.rs 431 31 92.81% 184, 198, 199, 200, 201, 202, 203, 204, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/pypi/src/lockfile.rs 393 25 93.64% 26, 27, 28, 43, 44, 45, 62, 63, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/cache.rs 123 22 82.11% 25, 26, 27, 28, 29, 30, 31, 32, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/config/mod.rs 171 20 88.30% 196, 197, 198, 209, 295, 296, 297, 298, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/cargo/src/lockfile.rs 308 20 93.51% 27, 28, 29, 44, 45, 46, 60, 67, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/bin/safe-pkgs-mcp.rs 37 16 56.76% 12, 13, 14, 15, 16, 18, 21, 22, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/npm/src/registry.rs 262 15 94.27% 65, 93, 94, 95, 96, 113, 114, 115, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/pypi/src/registry.rs 216 13 93.98% 49, 50, 51, 56, 57, 58, 117, 118, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/npm/src/lockfile.rs 294 13 95.58% 27, 28, 29, 44, 45, 46, 57, 93, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/typosquat/src/lib.rs 116 13 88.79% 64, 75, 78, 79, 87, 112, 154, 155, ...
/home/runner/work/safe-pkgs/safe-pkgs/src/registries/mod.rs 152 9 94.08% 58, 59, 60, 134, 154, 163, 164, 165, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/osv/src/lib.rs 147 9 93.88% 12, 13, 14, 15, 16, 17, 18, 19, ...
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/cargo/src/registry.rs 192 8 95.83% 38, 39, 40, 45, 46, 47, 211, 213
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/existence/src/lib.rs 48 3 93.75% 36, 37, 38
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/advisory/src/lib.rs 116 3 97.41% 68, 129, 142
/home/runner/work/safe-pkgs/safe-pkgs/src/audit_log.rs 58 2 96.55% 70, 124
/home/runner/work/safe-pkgs/safe-pkgs/src/support_map.rs 142 1 99.30% 58
/home/runner/work/safe-pkgs/safe-pkgs/crates/http/src/lib.rs 162 1 99.38% 138
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/pypi/src/lib.rs 13 0 100.00% -
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/npm/src/lib.rs 13 0 100.00% -
/home/runner/work/safe-pkgs/safe-pkgs/crates/registry/cargo/src/lib.rs 13 0 100.00% -
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/version-age/src/lib.rs 66 0 100.00% -
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/popularity/src/lib.rs 81 0 100.00% -
/home/runner/work/safe-pkgs/safe-pkgs/crates/checks/install-script/src/lib.rs 55 0 100.00% -

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR introduces a shared HTTP client utility crate (safe-pkgs-registry-http) that consolidates HTTP request handling, retry logic, error mapping, and user-agent configuration across all registry clients (PyPI, npm, Cargo) and the OSV advisory client.

Changes:

  • Created new safe-pkgs-registry-http crate with utilities for HTTP client building, retry/backoff logic, error handling, and JSON parsing
  • Refactored PyPI, npm, Cargo, and OSV clients to use shared HTTP utilities instead of duplicated per-crate implementations
  • Removed registry-specific user-agent constants and custom retry logic in favor of centralized implementations

Reviewed changes

Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.

Show a summary per file
File Description
crates/http/src/lib.rs New shared HTTP utilities crate with retry policy, client builder, error mappers, and JSON parser
crates/http/Cargo.toml Cargo manifest for new HTTP utilities crate
crates/registry/pypi/src/registry.rs Refactored to use shared HTTP utilities, removed PYPI_USER_AGENT constant
crates/registry/pypi/Cargo.toml Added dependency on safe-pkgs-registry-http
crates/registry/npm/src/registry.rs Refactored to use shared HTTP utilities, removed custom retry loop and NPM_DOWNLOAD_API_MAX_RETRY_ATTEMPTS constant
crates/registry/npm/Cargo.toml Added dependency on safe-pkgs-registry-http
crates/registry/cargo/src/registry.rs Refactored to use shared HTTP utilities, removed CRATES_IO_USER_AGENT constant
crates/registry/cargo/Cargo.toml Added dependency on safe-pkgs-registry-http
crates/osv/src/lib.rs Refactored to use shared HTTP utilities, updated test assertion for new error message format
crates/osv/Cargo.toml Added dependency on safe-pkgs-registry-http
CONTRIBUTING.md Added documentation for shared HTTP utilities usage guidelines
README.md Removed completed roadmap item about shared HTTP utilities
Cargo.toml Added crates/http to workspace members
Cargo.lock Updated with new crate and dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@math280h math280h merged commit f5b825a into main Feb 26, 2026
9 checks passed
@math280h math280h deleted the chore/shared-http-client branch February 26, 2026 02: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.

2 participants