Skip to content

fix: preserve absent components across Serialization roundtrip - #76

Open
theogf wants to merge 3 commits into
JuliaWeb:masterfrom
theogf:tgf/fix-serialization-roundtrip
Open

theogf wants to merge 3 commits into
JuliaWeb:masterfrom
theogf:tgf/fix-serialization-roundtrip

Conversation

@theogf

@theogf theogf commented Aug 26, 2026

Copy link
Copy Markdown

URI distinguishes an absent component from an empty one using a sentinel SubString (absent) identified by object identity (===). The default Serialization machinery round-trips field values but not object identity, so a deserialized URI's components were no longer === to absent, corrupting URIs built from components (e.g. a file: URI gaining a bogus empty authority). Serialize/deserialize through the URI string instead.

Fixes #75

Written by Claude Opus and manually checked.

URI distinguishes an absent component from an empty one using a
sentinel SubString (`absent`) identified by object identity (`===`).
The default Serialization machinery round-trips field values but not
object identity, so a deserialized URI's components were no longer
`===` to `absent`, corrupting URIs built from components (e.g. a
`file:` URI gaining a bogus empty authority). Serialize/deserialize
through the URI string instead.

Fixes JuliaWeb#75

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@codecov

codecov Bot commented Aug 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.56%. Comparing base (859a10c) to head (a0e095e).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #76      +/-   ##
==========================================
+ Coverage   86.91%   87.56%   +0.65%     
==========================================
  Files           5        5              
  Lines         382      402      +20     
==========================================
+ Hits          332      352      +20     
  Misses         50       50              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@quinnj

quinnj commented Aug 26, 2026

Copy link
Copy Markdown
Member

Thanks! One blocker: this breaks data serialized by existing releases. The old format has eight fields, but the new reader consumes only one, which misaligns the stream. For example:

# Written by the current release, then read by this PR:
(URI(; scheme="file", path="some/relative/path.pdf"), 42)

# Becomes:
(URI(""), "file")

Could we add a format marker, a backward-compatible reader, and a regression test with a trailing value?

@quinnj

quinnj commented Sep 3, 2026

Copy link
Copy Markdown
Member

Thanks, the stream-alignment issue is fixed. One legacy case remains: empty components are always converted to absent. A v1.7-serialized URI("http://example.com?") loses the ? after a later component update. Could we reparse a nonempty cached uri after consuming the legacy fields and add a regression test for this case? Cacheless legacy values can keep the documented best-effort fallback.

This branch has not been deployed

No deployments
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.

Serialization roundtrip corrupts URI

2 participants