Skip to content

Conversation

@katrinafyi
Copy link
Contributor

idk if this was an intentional change in the rate limiting change. the change happened because enum Status has special logic for detecting error kinds, but this only happens when From<reqwest::Error> is invoked, and not From<ErrorKind>. the logic says that some reqwest errors get treated as different status depending on their type. in particular, the data URI case got an Unsupported status.

the rate limiting change did an extra .into() (via ?) which converted a reqwest error into an ErrorKind, and this happened before the into Status conversion.

this PR fixes the bug by changing From<ErrorKind> for Status to dispatch to From<reqwest::Error> for Status in the BuildRequestClient case. this allows ErrorKind::BuildRequestClient to also be treated as Unsupported

along the way, i also turn TryFrom<&Url> for HostKey into From<&Url> for HostKey, by setting a fallback hostname when the URL has none of its own. this should be conceptually fine, but maybe it will be surprising if it turns up in user-facing output. this could be worked around another way if desired.

Fixes #1980

idk if this was an intentional change in the rate limiting change. the
change happened because `enum Status` has special logic for detecting
error kinds, but this only happens when `From<reqwest::Error>` is
invoked, and not `From<ErrorKind>`. the logic says that some reqwest
errors get treated as different status depending on their type. in
particular, the data URI case got an Unsupported status.

the rate limiting change did an extra .into() (via ?) which converted a
reqwest error into an ErrorKind, and this happened _before_ the into
Status conversion. ErrorKinds are universally turned into Error statuses

along the way, i also turn `TryFrom<&Url> for HostKey` into `From<&Url> for HostKey`,
by setting a fallback hostname when the URL has none of its own. this
should be conceptually fine, but maybe it will be surprising if it turns
up in user-facing output.

Fixes https://www.github.com/lycheeverse/lychee/issues/1980
@katrinafyi
Copy link
Contributor Author

it seems like setting a fallback hostname is not the way to go? at least, the tests don't like it. feedback would be appreciated.

that said, i do feel like it shouldn't be an error if there's no hostname... not sure

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.

data: URLs rejected by latest

1 participant