Skip to content

各 fetcher を route 文字列ベースのページネーションに切り替える#23

Merged
zaimy merged 1 commit into
masterfrom
migrate-to-route-strings
Apr 24, 2026
Merged

各 fetcher を route 文字列ベースのページネーションに切り替える#23
zaimy merged 1 commit into
masterfrom
migrate-to-route-strings

Conversation

@zaimy
Copy link
Copy Markdown
Contributor

@zaimy zaimy commented Apr 24, 2026

Summary

octocrab 最新版では Octocrab::absolute_url() が削除されており、次のメジャーバージョンアップに備えて、事前にこの依存を取り除きます。

Changes

  • UrlConstructor トレイトの entrypoint() -> Option<Url>entrypoint_route() -> String に変更
  • 各 fetcher の初回ページ取得を self.octocrab.get(route_str, None::<&()>) に書き換え。後続ページは従来どおり get_page(&page.next)
  • octocrab 0.8.13 の Octocrab::get<R, A: AsRef<str>, P> は route 文字列を直接受け取れるため、今の octocrab のままでこの変更は成立します

Review points

  • Cargo.toml は変更なし。octocrab のバージョンは 0.8.13 のまま
  • reqwest::Url の import は構造体のフィールド型として各所に残存しています。次のバージョンアップ PR で削除します
  • 既存テスト (src/issues.rstest_convert_issue_model) は無改修で通ります

Context

octx に GitHub App installation token 認証を追加する準備として、3 本に分割した PR のうちの 1 本目です。2 本目で octocrab を 0.49.x に上げ、3 本目で App 認証を追加します。

本 PR では Cargo.toml の version は上げません。3 本マージ完了後にまとめて bump する想定です。

Replace absolute_url()-based URL construction with passing route
strings directly to Octocrab::get(), which already accepts any
AsRef<str>. The UrlConstructor trait now exposes entrypoint_route()
returning String instead of entrypoint() returning Option<Url>.

This prepares for the upcoming octocrab bump where absolute_url()
has been removed.
@zaimy zaimy marked this pull request as ready for review April 24, 2026 01:38
Copy link
Copy Markdown

@n01e0 n01e0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

octcrab.getは内部でUri::from_str呼んでるっぽいので、absolute_urlにした方が良さそうです

Comment thread src/commits.rs
Comment thread src/events.rs
Comment thread src/comments.rs
Comment thread src/comments.rs
Comment thread src/issues.rs
Comment thread src/workflows.rs
Comment thread src/workflows.rs
Comment thread src/workflows.rs
Comment thread src/workflows.rs
Comment thread src/users_detailed.rs
@zaimy
Copy link
Copy Markdown
Contributor Author

zaimy commented Apr 24, 2026

@n01e0
レビューありがとうございます。少し事情を共有させてください。

まず本 PR は 3 本に分割した octx 改修の 1 本目で、次の PR で octocrab を 0.49.x にバージョンアップするためのリファクタになっています。octocrab は 0.21 以降で reqwest 依存を撤廃しており、それに伴って 0.49 では Octocrab::absolute_url() が削除されています ( https://github.com/XAMPPRocky/octocrab/blob/v0.49.7/src/lib.rs に該当メソッドなし)。次の PR で absolute_url 呼び出しを全部書き換える必要があり、本 PR ではそれを先行して排除する形を取っています。

また /repos/... ではなく repos/... にしているのは、octx が GHES (GITHUB_API_URL=https://git.example.com/api/v3/ のような base URL) でも使われているためです。先頭スラッシュを付けると url::Url::join のセマンティクスで path prefix /api/v3/ が落ちてしまうので、ここは先頭スラッシュなしで進めさせてください。実際に url::Url::join の挙動を確認しました。

base                               + route           => result
https://api.github.com/            + repos/foo/bar   => https://api.github.com/repos/foo/bar            ✅
https://api.github.com/            + /repos/foo/bar  => https://api.github.com/repos/foo/bar            ✅ (同じ)
https://git.example.com/api/v3/    + repos/foo/bar   => https://git.example.com/api/v3/repos/foo/bar    ✅
https://git.example.com/api/v3/    + /repos/foo/bar  => https://git.example.com/repos/foo/bar           ❌

GHES の場合に leading slash を付けると path prefix /api/v3/ が落ちる挙動になります( RFC 3986 Section 5.3 準拠)。
以上の理由で、本 PR では route 文字列を直接 get に渡す現状のまま進めたいのですが、いかがでしょうか。

Copy link
Copy Markdown

@n01e0 n01e0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bump-octcrab の方のブランチ見ながらこっちにコメントしてました…
すみません 🙇

@zaimy
Copy link
Copy Markdown
Contributor Author

zaimy commented Apr 24, 2026

レビューありがとうございます!!

@zaimy zaimy merged commit 124199b into master Apr 24, 2026
1 check passed
@zaimy zaimy deleted the migrate-to-route-strings branch April 24, 2026 06:02
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.

2 participants