Inconsistent redirect behaviors for platform-specific items
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 1.2k
- Forks
- 232
- Avg merge
- 11h 35m
- Merged PRs (30d)
- 60
Description
Hello! I found some cases, related to platform-specific items, where docs.rs doesn't reliably redirect to the search page when the requested item doesn't exist.
(I imagine most of these only really happen if someone's writing URLs by hand. I found them while experimenting with programmatically generating links to docs.rs for my project)
-
If the URL doesn't specify or specifies the default target of a crate, then docs.rs returns the blank "requested resource does not exist" page, whereas if the URL specifies a non-default target, then it redirects to search:
- This returns 302: https://docs.rs/nix/0.31.2/aarch64-apple-ios/nix/kmod/index.html
- This returns 404: https://docs.rs/nix/0.31.2/nix/macro.request_code_write_int.html
- This returns 404 after a 302: https://docs.rs/nix/0.31.2/x86_64-unknown-linux-gnu/nix/macro.request_code_write_int.html
- The corresponding
target-redirectlink works fine: https://docs.rs/crate/nix/0.31.2/target-redirect/nix/macro.request_code_write_int.html
-
If the URL specifies a target that doesn't exist for a crate/version, then docs.rs returns 404:
- For example: https://docs.rs/nix/0.31.2/x86_64-pc-windows-msvc/nix/kmod/index.html
- The corresponding
target-redirectlink works fine: https://docs.rs/crate/nix/0.31.2/target-redirect/x86_64-pc-windows-msvc/nix/kmod/index.html - This was mentioned in #1416 so a regression perhaps?
On this topic I also have a question/proposal: Would it make sense or be feasible, when the URL doesn't specify a target, to try locating the item in all targets, and redirect to the first target if the item was found?
Still using nix as an example: nix@0.31.2 has x86_64-unknown-linux-gnu as the default target, which doesn't have the item nix/sys/termios/fn.cfmakesane.html, but the target x86_64-unknown-freebsd does:
- Right now, https://docs.rs/nix/0.31.2/nix/sys/termios/fn.cfmakesane.html returns 404 (which I suppose should instead be the search page)
- I'm wondering if this would make more sense:
- https://docs.rs/nix/0.31.2/x86_64-unknown-linux-gnu/nix/sys/termios/fn.cfmakesane.html goes to search, which is the current behavior (because the URL specifically asked for that platform);
- https://docs.rs/nix/0.31.2/nix/sys/termios/fn.cfmakesane.html will redirect to https://docs.rs/nix/0.31.2/x86_64-unknown-freebsd/nix/sys/termios/fn.cfmakesane.html
So instead of interpreting a URL without a target as "the default target," perhaps interpret it as "target unspecified"?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the listed docs.rs URLs and trace the existing target-redirect and missing-item handling. Compare behavior for default, explicit, nonexistent, and unspecified targets; the work is done when the intended redirect or search-page behavior is consistent and covered by the project's relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100