servo / servo/rust-url

Fix `serde::Deserialize` impl for `Url` prints confusing error message

Open
#861 0 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
406
PR merge metrics
No merged PRs in 30d

Description

When failing to deserialize a str into a Url the current implementation of Deserialize returns an error with a confusing message.

For example:

use serde_json::{json, Result};
use url::Url;

let json = json!("bad_url");
let result: Result<Url> = serde_json::from_value(json);
println!("{}", result.err().unwrap());

Actual: invalid value: string "bad_url", expected relative URL without a base
Expected: invalid value: string "bad_url", expected a string representing a URL

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the serde::Deserialize implementation for Url and reproduce the serde_json example from the issue to confirm the current error text. Update the reported expectation so invalid strings produce the clearer message, then run the relevant test suite and verify the example's output matches the expected wording.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.