Skip to content

Encode URL serialization policies in the type system - #2711

Closed
zaniebot wants to merge 1 commit into
zaniebot/safe-url-rename-20261014from
zaniebot/safe-url-policies-20261014
Closed

zaniebot wants to merge 1 commit into
zaniebot/safe-url-rename-20261014from
zaniebot/safe-url-policies-20261014

Conversation

@zaniebot

@zaniebot zaniebot commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

SafeUrl currently serializes the full URL, so fields can persist credentials without an explicit choice. Add a type-level policy that defaults to Unserializable; Stripped removes sensitive userinfo while retaining the complete query, and Raw serializes the full parsed URL. Display and Debug remain redacted. Index URLs in pylock.toml and publish URLs in tool receipts use Stripped.

This is an alternative to astral-sh#22356, astral-sh#22357, and astral-sh#22358, combined in #2712. Stripped and Raw follow the same serialization rules as PersistSafeUrl and CredentialPersistingUrl. Using SafeUrl<P> carries the policy through VerbatimUrl, stored fields, and transformations such as join; shared implementations are generic over the policy. The inherent serialize and serialize_internal methods prevent fallback through Deref; the latter requires Raw. The comparison stack also changes how DirectUrl metadata is parsed and written; this PR retains its string fields and existing behavior.

Stacked on #2721.

@zaniebot
zaniebot deployed to automations October 14, 2026 15:52 — with GitHub Actions Active
@codspeed

codspeed Bot commented Oct 14, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 13.01%

⚠️ 8 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 1 regressed benchmark
✅ 68 untouched benchmarks
⏩ 35 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ ⚠️ Simulation discover_workspace_from_all_members_with_excludes 142.7 ms 164.1 ms -13.01%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing zaniebot/safe-url-policies-20261014 (3dff9d7) with zaniebot/safe-url-rename-20261014 (f85db54)

Open in CodSpeed

Footnotes

  1. 35 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@zaniebot
zaniebot deployed to automations October 14, 2026 16:54 — with GitHub Actions Active
@zaniebot
zaniebot deployed to automations October 14, 2026 16:59 — with GitHub Actions Active
Comment thread crates/uv-redacted/src/lib.rs Resolved
@zaniebot
zaniebot deployed to automations October 14, 2026 17:03 — with GitHub Actions Active
@zaniebot
zaniebot force-pushed the zaniebot/safe-url-policies-20261014 branch from 560311a to 3440d01 Compare October 14, 2026 17:17
@zaniebot
zaniebot changed the base branch from main to zaniebot/safe-url-rename-20261014 October 14, 2026 17:17
@zaniebot
zaniebot deployed to automations October 14, 2026 17:18 — with GitHub Actions Active
@zaniebot
zaniebot force-pushed the zaniebot/safe-url-policies-20261014 branch from 3440d01 to 0a8c6e8 Compare October 14, 2026 17:23
@zaniebot
zaniebot deployed to automations October 14, 2026 17:27 — with GitHub Actions Active
@astral-automations-bot
astral-automations-bot Bot force-pushed the zaniebot/safe-url-rename-20261014 branch 2 times, most recently from 7475136 to 48a3f34 Compare October 14, 2026 18:15
@zaniebot
zaniebot force-pushed the zaniebot/safe-url-policies-20261014 branch from 0a8c6e8 to ee704db Compare October 14, 2026 18:25
@zaniebot
zaniebot deployed to automations October 14, 2026 18:26 — with GitHub Actions Active
@astral-automations-bot
astral-automations-bot Bot force-pushed the zaniebot/safe-url-rename-20261014 branch from 48a3f34 to f85db54 Compare October 15, 2026 08:07
@zaniebot
zaniebot force-pushed the zaniebot/safe-url-policies-20261014 branch from ee704db to 3b9c144 Compare October 15, 2026 14:35
@zaniebot
zaniebot deployed to automations October 15, 2026 14:36 — with GitHub Actions Active
Comment on lines -204 to +205
self.inner().without_credentials().serialize(serializer)
self.inner().serialize(serializer)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

love to see it

Comment thread crates/uv-pypi-types/src/direct_url.rs Outdated
Comment on lines +16 to +20
/// Direct URL metadata whose URL has not yet been parsed.
#[derive(Deserialize)]
#[serde(transparent)]
// The unparsed URL may contain credentials, so this wrapper omits `Serialize` and `Debug`.
pub struct DirectUrlMetadata(DirectUrl<String>);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hm, not sure why this exist, need to look into it

@zaniebot
zaniebot force-pushed the zaniebot/safe-url-policies-20261014 branch from 3b9c144 to 5656488 Compare October 15, 2026 15:44
@zaniebot
zaniebot deployed to automations October 15, 2026 15:45 — with GitHub Actions Active
@zaniebot
zaniebot force-pushed the zaniebot/safe-url-policies-20261014 branch from 5656488 to 3dff9d7 Compare October 15, 2026 16:49
@zaniebot
zaniebot deployed to automations October 15, 2026 16:50 — with GitHub Actions Active
@zanieb
zanieb marked this pull request as ready for review October 15, 2026 17:33
@astral-automations-bot

Copy link
Copy Markdown

Promoted to #22600.

This branch was successfully deployed

1 active deployment
automations — 3dff9d71 Deployed Oct 15, 2026 by zaniebot via review-code-quality / code quality review #10412
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