feat(check): add check for URL correctness + double slashes - #944
Conversation
📝 WalkthroughWalkthroughThe check crate adds a graph-based checker for web source URLs, validates URL syntax, schemes, and path slashes, integrates its result into package checks, and adds tests covering pass, fail, and skip outcomes. ChangesSource URL validation
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant PackageChecker
participant SourceUrlsValid
participant BuildGraph
participant CheckResult
PackageChecker->>SourceUrlsValid: run checker
SourceUrlsValid->>BuildGraph: find package and build dependencies
BuildGraph-->>SourceUrlsValid: return web sources
SourceUrlsValid->>SourceUrlsValid: parse and validate URLs
SourceUrlsValid-->>CheckResult: produce pass, fail, or skip
CheckResult-->>PackageChecker: aggregate checker outcome
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/check/src/sources.rs`:
- Around line 141-156: Remove the CARGO_MANIFEST_DIR mutation and restoration
around Layer::new_for_test in the affected test. Update the parsing flow to
receive the stdlib resolver root explicitly, or isolate it in a child process,
so it does not rely on ENV_LOCK or process-wide environment state.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 32089a5b-b970-46a2-9d5b-96e781ab54bf
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (3)
crates/check/Cargo.tomlcrates/check/src/lib.rscrates/check/src/sources.rs
| let _guard = ENV_LOCK.lock().expect("env lock"); | ||
| let prev_manifest_dir = std::env::var_os("CARGO_MANIFEST_DIR"); | ||
| // SAFETY: every test that mutates CARGO_MANIFEST_DIR does so while | ||
| // holding ENV_LOCK, and no other code in this test binary reads the | ||
| // variable, so this set never races with another thread's access. | ||
| unsafe { | ||
| std::env::set_var("CARGO_MANIFEST_DIR", &stdlib); | ||
| } | ||
| let parsed = Layer::new_for_test(nickel.to_string()); | ||
| // SAFETY: same invariant as the set above — still under ENV_LOCK. | ||
| unsafe { | ||
| match prev_manifest_dir { | ||
| Some(v) => std::env::set_var("CARGO_MANIFEST_DIR", v), | ||
| None => std::env::remove_var("CARGO_MANIFEST_DIR"), | ||
| } | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | 🏗️ Heavy lift
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
fd -t f -e rs '^outputs\.rs$' crates --exec ast-grep outline {} --items all
rg -n -C2 'CARGO_MANIFEST_DIR|std::env::(set_var|remove_var|var_os)' crates --type rustRepository: gominimal/minimal
Length of output: 29919
🏁 Script executed:
#!/bin/bash
set -euo pipefail
sed -n '1,240p' crates/check/src/sources.rs
echo '---'
sed -n '1,220p' crates/check/src/outputs.rs
echo '---'
sed -n '1,220p' crates/mip/src/cmd_dep.rsRepository: gominimal/minimal
Length of output: 25842
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '\n== check Cargo.toml for test/runtime features ==\n'
sed -n '1,220p' crates/check/Cargo.toml
printf '\n== sources.rs test annotations and nearby helpers ==\n'
rg -n -C2 '#\[tokio::test\]|serial_test|ENV_LOCK|graph_with_pkg|Layer::new_for_test' crates/check/src/sources.rs
printf '\n== outputs.rs test annotations and nearby helpers ==\n'
rg -n -C2 '#\[tokio::test\]|serial_test|ENV_LOCK|graph_with_pkg|Layer::new_for_test' crates/check/src/outputs.rs
printf '\n== any crate-local test serialization or env-lock patterns ==\n'
rg -n -C2 'static ENV_LOCK|serial_test|#[[:space:]]*test|tokio::test' crates/check/src crates/check/tests crates/check/Cargo.tomlRepository: gominimal/minimal
Length of output: 15270
Remove the process-wide env mutation here. ENV_LOCK only serializes callers in this module, while crates/check/src/outputs.rs mutates CARGO_MANIFEST_DIR under a separate lock. In async tests this still leaves a process-wide race; pass the resolver root explicitly or isolate the parse in a child process.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/check/src/sources.rs` around lines 141 - 156, Remove the
CARGO_MANIFEST_DIR mutation and restoration around Layer::new_for_test in the
affected test. Update the parsing flow to receive the stdlib resolver root
explicitly, or isolate it in a child process, so it does not rely on ENV_LOCK or
process-wide environment state.
Makes the issue from gominimal/pkgs#516 a check error.
Note
Add URL correctness check for web sources in
check_packageAdds a new
SourceUrlsValidgraph-based checker in sources.rs that validates URLs on webSourcebuild dependencies. The checker fails on unparseable URLs, unsupported schemes (onlyhttp,https, andgsare allowed), or double slashes in the URL path, and respectsskip_checkers.Macroscope summarized 81b4cbc.
Summary by CodeRabbit
New Features
http,https, andgs), and accidental double slashes in paths.Tests