Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Uri Builder path change broke parsing and reconstructing the Uri with empty path

Aperta
#846 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
62/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
rust
Ambito
api, backend

Direzione di ricerca

Inizia dalla gestione di path_and_query nel percorso Uri::builder mostrata nell’issue e confronta il suo comportamento tra http v1.4.0 e v1.4.1. Aggiungi un test di regressione per ricostruire un Uri con un percorso vuoto, quindi esegui i test pertinenti del builder e del parsing di Uri per confermare che l’esempio abbia successo.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Version

http v1.4.1

Platform

Linux 6.8.0-111-generic Ubuntu 24.04

Summary

Uri Builder path change broke parsing and reconstructing the Uri with empty path.
In example below the path returns empty string.

This used to work fine to sanitize/cleanup a provided Url string, which I think is a common pattern people use.

As Uri.path() always returns a string and not an Option<String> its not intuitive that this stops working.

Also what is a bit annoying is that this broke in a patch update version.
Took me a while to figure out that an auto update of this dependency broke this behavior.

Code Sample
    let uri = Uri::from_str("example.com")?;
    let final_uri = Uri::builder()
        .scheme(uri.scheme_str().unwrap_or("https"))
        .authority(uri.authority()?.as_str())
        .path_and_query(uri.path())
        .build();
Expected Behavior

In v1.4.0 this used to work.

final_uri = Ok(Uri(...))
Actual Behavior

Since v1.4.1 this fails now.

final_uri = Err(http::Error(InvalidUri(Empty)))
Additional Context

If this is just intended and works as designed then feel free to close this.

Workaround I needed to add:

    let path = if !path.starts_with("/") {
        "/".to_string() + path
    } else {
        path.to_string()
    };
Lingua principale
Rust
Stelle
1.4k
Fork
380
Merge medio
2g 5h
PR unite (30g)
4

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di hyperium/http

Tutte le issue di hyperium/http

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.