oxidecomputer / oxidecomputer/third-party-api-clients

request_with_links() does not distinguish between multiple 'link' response headers

Open
#105 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
150
Forks
62
PR merge metrics
No merged PRs in 30d

Description

Some of the paginated API's, for example /users, return double 'link' headers in the response. It seems the request_with_links() doesn't distinguish between the two and depending on the order picks one of the two; which might lead to unexpected behaviour if the link is to 'self'.

See Okta::request_with_links:

async fn request_with_links<Out>(
        &self,
        method: http::Method,
        uri: &str,
        message: Message,
    ) -> ClientResult<(Option<crate::utils::NextLink>, crate::Response<Out>)>
    where
        Out: serde::de::DeserializeOwned + 'static + Send,
    {
        let response = self.request_raw(method, uri, message).await?;

        let status = response.status();
        let headers = response.headers().clone();
        let link = response
            .headers()
           // HERE: if there are two 'link' headers, which one is it getting?
            .get(http::header::LINK)
            .and_then(|l| l.to_str().ok())
            .and_then(|l| parse_link_header::parse(l).ok())
            .as_ref()
            .and_then(crate::utils::next_link);
...

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

Start at Okta::request_with_links and inspect how response.headers() handles repeated LINK values before parse_link_header::parse and crate::utils::next_link. Reproduce a response with two Link headers, then verify that pagination chooses the intended link consistently rather than depending on header order.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.