xampprocky / octocrab Goto Github PK
View Code? Open in Web Editor NEWA modern, extensible GitHub API Client for Rust.
License: Other
A modern, extensible GitHub API Client for Rust.
License: Other
Hi, I'm trying to use this to do bulk permission updates in our org, and ran into a couple issues (and possible solutions).
In src/api/teams/team_repos.rs
, both check_manages
and add_or_update
try to request a relative URL directly via reqwest, which fails with the error Error: Http { source: reqwest::Error { kind: Builder, source: RelativeUrlWithoutBase }
. I have a local fork and found that calling self.crab.absolute_url(&url)?
fixes the issue. I see there's also a way to call Octocrab::get
or Octocrab::put
which handles relative API URLs, but I couldn't find the best way to make the types line up.
I also found an issue with the add_or_update
body payload. It serializes a params::teams::Permission
directly into the body, resulting in the body having just the string of the desired permission, (such as "admin"
), but the API requires it be in the form {"permission": "admin"}
. I fixed this with a private one-field struct:
#[derive(Debug, serde::Serialize)]
struct PermissionUpdateBody {
permission: params::teams::Permission,
}
I can open a PR with these fixes if you'd like, I'd just like some guidance on which way to take the relative URL fix (calling Octocrab::absolute_url
or Octocrab::get/put
) and where to put the permission update type.
Though #124 adds a new option to exclude pull requests in the response but
by default pull requests field is included in the response.
"previous_attempt_url": null,
"pull_requests": [
{
"base": {
"ref": "main",
"repo": {
"id": 363008902,
"name": "linkerd2",
"url": "https://api.github.com/repos/Mu-L/linkerd2"
},
"sha": "cae8813e04de79a28cc4259a757ecb21ad39f1b7"
},
"head": {
"ref": "main",
"repo": {
"id": 113106184,
"name": "linkerd2",
"url": "https://api.github.com/repos/linkerd/linkerd2"
},
"sha": "1bea04c133b5027ac438f447b77966d250c2bdb8"
},
"id": 651803667,
"number": 14,
"url": "https://api.github.com/repos/Mu-L/linkerd2/pulls/14"
},
{
"base": {
"ref": "main",
"repo": {
"id": 346934370,
"name": "linkerd2",
"url": "https://api.github.com/repos/kokizzu/linkerd2"
},
"sha": "cae8813e04de79a28cc4259a757ecb21ad39f1b7"
},
"head": {
"ref": "main",
"repo": {
"id": 113106184,
"name": "linkerd2",
"url": "https://api.github.com/repos/linkerd/linkerd2"
},
"sha": "1bea04c133b5027ac438f447b77966d250c2bdb8"
},
"id": 651078450,
"number": 66,
"url": "https://api.github.com/repos/kokizzu/linkerd2/pulls/66"
},
{
"base": {
"ref": "main",
"repo": {
"id": 286760465,
"name": "linkerd2",
"url": "https://api.github.com/repos/rizalgowandy/linkerd2"
},
"sha": "89c4126d904c61b5f706313ceb6ef65c09578331"
},
"head": {
"ref": "main",
"repo": {
"id": 113106184,
"name": "linkerd2",
"url": "https://api.github.com/repos/linkerd/linkerd2"
},
"sha": "1bea04c133b5027ac438f447b77966d250c2bdb8"
},
"id": 621691631,
"number": 243,
"url": "https://api.github.com/repos/rizalgowandy/linkerd2/pulls/243"
}
],
But this does not match the type of Run.PullRequests
which is a vec
of PullRequest
and PullRequest has a lot of fields that should not be nil, causing the API to show a serde error: missing field node_id
.
This can be fixed in the following ways:
PullRequest
type that only includes the above known fields (from the response) in the workflows.rs
file.Option
in PullRequest
struct from pulls.rs
(which includes a lot of them)I'm happy to raise a PR, and work on this once I get a response on the solution that we have to take.
Thanks,
Tarun
https://docs.github.com/en/rest/reference/issues#add-assignees-to-an-issue
assignees | array of strings | body | Usernames of people to assign this issue to
&self,
number: u64,
assignees: &[u64],
) -> Result<models::issues::Issue> {
I don't know who's right but I hope the Github docs are right...
This is a tracking issue for the search API endpoints.
Seems to me it would be nice to have newtypes for the different IDs (orgs, users, check runs, workflow runs, etc). That would be an API break though. How do you feel about that?
It's currently quite cumbersome to iterate over pages on a resource.
It would be great if resources that return a list with multiple pages instead return an iterator that makes it easy to iterate over elements and have the iterator automatically fetch subsequent pages.
Instead of this:
pub async fn org_hooks(&self) -> Result<Vec<Hook>, Error> {
let mut current_page: Page<Hook> = self
.octocrab
.get(
format!("/orgs/{}/hooks", self.config.organization),
None::<&()>,
)
.await?;
let mut results = current_page
.total_count
.map_or_else(Vec::new, |n| Vec::with_capacity(n as usize));
results.extend(current_page.take_items());
while let Some(mut page) = self.octocrab.get_page::<Hook>(¤t_page.next).await? {
results.extend(page.take_items());
current_page = page;
}
Ok(results)
}
I imagine something like this:
pub async fn org_hooks(&self) -> Result<Vec<Hook>, Error> {
let mut hooks = self.octocrab
.get_iter(
format!("/orgs/{}/hooks", self.config.organization),
None::<&()>,
)
.await?;
let result = hooks.collect::<Vec<Hook>>.await?;
Ok(results)
}
I'm getting a stack overflow when trying to deserialize a roughly 15k response.
let pull_request = octo
.pulls("owner", "repo")
.get(issue_comment.issue.number as _)
.await
.unwrap();
The response is valid JSON (I tried using serde_json
to deserialize it myself).
The stack overflow is happening somewhere in the call to serde_path_to_error
:
Line 15 in ac8ed2e
My assumption is that it uses a lot of stack space for what it's doing.. but I haven't read the code and I'm not sure how easy to hard it would be to fix the overflow.
Would it be reasonable to just remove this dependency? Since it should be relatively straightforwards to track down where a field that is causing an error lives should someone ever run into that situation, I think.
EDIT: Ah, I guess I can use ._get
even if you end up keeping serde_path_to_error
. Sweet!
Hey!
I'd like to add CheckRun
and CheckSuite
variants to the EventPayload
.
octocrab/src/models/events/payload.rs
Line 36 in 9e82499
Just confirming that those would be accepted contributions before I invest time in this?
Thanks!
In order to be more client agnostic, and allow using Octocrab in more places, I would like to remove reqwest
and replace it entirely with http
, tower
, and hyper
. Using the same approach as kube-rs
.
If anyone is interested in taking this on, I would make a PR per endpoint or endpoint group, and not move all of them at once. Feel to ask on the issue or in the discussion board if you need help.
On the events and notifications API's (possible other API's) GitHub will return a header, x-poll-interval
, which specifies how often in seconds you are allowed to poll. See the documentation on this for more info.
On some API's the interval is quite large, for example the /events
API has an x-poll-interval
header set to 60 but to get all the events you really need to poll and fetch pages every second or two. See this community post for more info.
Regardless of that, it would be good to expose this header to consumers of octocrab
, similar to how we currently expose etags.
Hello, and thanks for building this awesome crate!
I'm currently trying to use octocrab to list pull requests on repos, and I'm experiencing some issues with GitHub errors. The problem is that GitHub is sending back some HTTP 502 error codes, and when it does, the documentation_url
field is not set in the request, which causes a panic.
Response {
url: Url {
scheme: "https",
cannot_be_a_base: false,
username: "",
password: None,
host: Some(
Domain(
"api.github.com",
),
),
port: None,
path: "/repos/rust-lang/rust/pulls",
query: Some(
"state=closed&per_page=14",
),
fragment: None,
},
status: 502,
headers: {
"server": "GitHub.com",
"date": "Mon, 16 Aug 2021 19:34:05 GMT",
"content-type": "application/json",
"content-length": "32",
"etag": "\"611ab88a-20\"",
"vary": "Accept-Encoding, Accept, X-Requested-With",
"x-github-request-id": "8583:5A9E:5B6593:1244875:611ABDA3",
},
}
The panic is :
Error: HTTP Error: error decoding response body: missing field `documentation_url` at line 3 column 1
Caused by:
0: error decoding response body: missing field `documentation_url` at line 3 column 1
1: missing field `documentation_url` at line 3 column 1
Error: HTTP Error: error decoding response body: missing field `documentation_url` at line 3 column 1
Found at 0 <snafu::backtrace_shim::Backtrace as snafu::GenerateBacktrace>::generate::ha7667e3035162ea3
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/snafu-0.6.10/src/backtrace_shim.rs:15
<octocrab::error::Http as snafu::IntoError<octocrab::error::Error>>::into_error::h8bd1e90cb9c22d06
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.9.1/src/error.rs:5
1 <core::result::Result<T,E> as snafu::ResultExt<T,E>>::context::{{closure}}::h807638accb6bcfd4
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/snafu-0.6.10/src/lib.rs:318
2 core::result::Result<T,E>::map_err::hac004b6fcf6e3132
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/result.rs:591
3 <core::result::Result<T,E> as snafu::ResultExt<T,E>>::context::h7e02ac3ac318786f
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/snafu-0.6.10/src/lib.rs:318
4 octocrab::map_github_error::{{closure}}::hb05a326bd2494a99
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.9.1/src/lib.rs:220
5 <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h45ed74b51552b2a4
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
6 octocrab::api::pulls::PullRequestHandler::http_get::{{closure}}::h15b19e1eb53045cc
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.9.1/src/api/pulls.rs:293
7 <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::hc4cfc890055f6ab6
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
8 octocrab::api::pulls::list::ListPullRequestsBuilder::send::{{closure}}::hd097bbd0881f7abd
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.9.1/src/api/pulls/list.rs:97
9 <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h9bceb81e58f5e3a0
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
10 <pr_bump_lib::github::GitHub as pr_bump_lib::github::GitHubOperations>::get_pulls_after::{{closure}}::h2f6ce96a07a9ee1b
/home/nmarier/Documents/Software/Projects/pr-bump/src/github.rs:131
11 <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h0238c16f2c60d3a2
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
12 <core::pin::Pin<P> as core::future::future::Future>::poll::h24ea91871ded703f
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/future.rs:119
13 pr_bump_lib::get_next_version::{{closure}}::h06fc4dc3f58cdca8
/home/nmarier/Documents/Software/Projects/pr-bump/src/lib.rs:28
14 <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h5af607a86d332153
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
15 pr_bump_bin::main::{{closure}}::h846a8c1ae8706dc0
/home/nmarier/Documents/Software/Projects/pr-bump/src/main.rs:21
16 <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::h4b93bb5ad029f515
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/future/mod.rs:80
17 tokio::park::thread::CachedParkThread::block_on::{{closure}}::h06faf992d6244e14
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/park/thread.rs:263
18 tokio::coop::with_budget::{{closure}}::hf41c18dcea21b465
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/coop.rs:106
19 std::thread::local::LocalKey<T>::try_with::h9880dac36a1109d0
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:272
20 std::thread::local::LocalKey<T>::with::hbbd66cc1648d9cf2
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/thread/local.rs:248
21 tokio::coop::with_budget::hf8874d6f2a753499
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/coop.rs:99
tokio::coop::budget::hfc7a2acb017051c4
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/coop.rs:76
tokio::park::thread::CachedParkThread::block_on::h584a78ee3d747c71
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/park/thread.rs:263
22 tokio::runtime::enter::Enter::block_on::h373b8369d4db622f
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/runtime/enter.rs:151
23 tokio::runtime::thread_pool::ThreadPool::block_on::h9de67c19bde17ab7
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/runtime/thread_pool/mod.rs:71
24 tokio::runtime::Runtime::block_on::he98ad56576faf958
/home/nmarier/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.9.0/src/runtime/mod.rs:452
25 pr_bump_bin::main::hc31b26531c3083ae
/home/nmarier/Documents/Software/Projects/pr-bump/src/main.rs:34
26 core::ops::function::FnOnce::call_once::hda83902ef96cb03a
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:227
27 std::sys_common::backtrace::__rust_begin_short_backtrace::h639bb6dcc12ae7e8
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/sys_common/backtrace.rs:125
28 std::rt::lang_start::{{closure}}::h3bcf282f721f8a31
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:66
29 core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h44574effd2120c86
/rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/core/src/ops/function.rs:259
std::panicking::try::do_call::h10b0bd4879c8dfb0
/rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:379
std::panicking::try::h60c6780d33419e92
/rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panicking.rs:343
std::panic::catch_unwind::h111f33e08c52e2ce
/rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/panic.rs:431
std::rt::lang_start_internal::h126f2e09345dbfda
/rustc/9bc8c42bb2f19e745a63f3445f1ac248fb015e53/library/std/src/rt.rs:51
30 std::rt::lang_start::h964559ef2ebfeea3
/home/nmarier/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/rt.rs:65
31 main
32 __libc_start_main
33 _start
Caused by:
0: error decoding response body: missing field `documentation_url` at line 3 column 1
1: missing field `documentation_url` at line 3 column 1
I believe the fix might be as simple as changing GitHubError
to have documentation_url: Option<String>
(in this file), but that would be a breaking change. Another idea would be to make a new BasicGitHubError
type (or something similar), and to add a check here to see if the documentation_url
exists. If it exists, create GitHubError
and if not, create BasicGitHubError
.
The github page allows searching pull requests by organization (see for example the weekly PRs link in this week in rust).
This allows a more fine grained query (as opposed to getting all queries and filtering them after the fact) and may help conserve bandwidth. It does need an authenticated user, though, as far as I know.
Using this crate: https://docs.rs/serde_path_to_error/0.1.2/serde_path_to_error/
Any plans to support the update releases endpoint?
P.S.: Thanks for this library, really nice!
Examples such as github_app_authentication
and github_app_authentication_manual
are no longer valid.
Here is an example of EncodingKey
not being able to be passed into octocrab::auth::create_jwt
while using EncodingKey.from_rsa_pem
.
let pem = std::fs::read_to_string(&config.private_key_path).expect("Something went wrong reading the file");
let key = jsonwebtoken::EncodingKey::from_rsa_pem(pem.as_bytes()).unwrap();
let jwt = octocrab::auth::create_jwt(AppId(config.application_id), key);
An error like the following is caused, given the above context:
error[E0277]: the trait bound `EncodingKey: AsRef<[u8]>` is not satisfied
--> src/main.rs:46:80
|
46 | let jwt = octocrab::auth::create_jwt(AppId(config.application_id), key).unwrap();
| ^^^ the trait `AsRef<[u8]>` is not implemented for `EncodingKey`
|
note: required by a bound in `create_jwt`
--> /home/xithrius/.cargo/registry/src/github.com-1ecc6299db9ec823/octocrab-0.13.0/src/auth.rs:22:22
|
22 | pub fn create_jwt<A: AsRef<[u8]>>(
| ^^^^^^^^^^^ required by this bound in `create_jwt`
I found myself getting deserialization errors like this using the graphql helper (despite propagating errors with ?
). I didn't anticipate having to handle errors myself.
Object({"data": Object({"repository": Null}), "errors": Array([Object({"locations": Array([Object({"column": Number(15), "line": Number(2)})]), "message": String("Could not resolve to a Repository with the name \'/millardjn/alumina\'."), "path": Array([String("repository")]), "type": String("NOT_FOUND")})])})
Since this is the standard GraphQL way of returning query errors, my suggestion would be to add a GraphqlErrors
type and internally make the request and deserialize into a type like below and automatically converting the Error variant into the actual octocrab::Error
type.
#[derive(Serialize, Deserialize)]
#[serde(untagged)]
enum GraphqlResponse<T> {
// order matters for untagged, since T could be something generic like serde_json::Value
Error(GraphqlErrors),
Value(T),
}
Add API for notifications
I just tried .get()
on a .repos()
to fetch some information but for some reason that wont work.
no method named `get` found for struct `RepoHandler` in the current scope
method not found in `RepoHandler<'_>`
Support for the Events API would be nice.
I'm trying to save octocrab::models::events::Event
s to a local database, and I've run into an issue when trying to restore the Json I've serialized using serde_json.
A problem example event payload looks like this (the watcher's details have been anonymized):
{
"id": "18645316253",
"type": {
"UnknownEvent": "WatchEvent"
},
"actor": {
"id": 000,
"login": "...",
"display_login": "...",
"gravatar_id": "",
"url": "https://api.github.com/users/...",
"avatar_url": "https://avatars.githubusercontent.com/u/...?"
},
"repo": {
"id": 247378701,
"name": "khonsulabs/kludgine",
"url": "https://api.github.com/repos/khonsulabs/kludgine"
},
"public": true,
"created_at": "2021-10-28T16:52:23Z",
"payload": {
"action": "started"
},
"org": {
"id": 50191483,
"login": "khonsulabs",
"gravatar_id": "",
"url": "https://api.github.com/orgs/khonsulabs",
"avatar_url": "https://avatars.githubusercontent.com/u/50191483?"
}
}
The error I get from the deserialization call is invalid type: map, expected a string at line 1 column 27
. I recognize that this library isn't designed for this purpose, and I'm skipping these events so this doesn't actually impact my project anymore.
This is a feature request, feel free to close this issue immediately if you hate it.
But it would be very convenient to be able to feed synthetic data to octocrab::Octocrab
so client code could easily write unit tests with consistent data (instead of manually making a github organization/repo, etc.)
You could call this test struct Moctocrab
๐
Say I had the following function (as I do in fact have ๐ ) that counted the number of PRs created in the last 30 days for the specified repository in the specified organization.
It would be nice to be able to write a unit test that passes in my customized/mocked octocrab::Octocrab
instance with pre-determined data so as to verify that this function works consistently and as expected.
use chrono::{Duration, Utc};
use fehler::throws;
#[throws]
async fn count_pull_requests(octo: &octocrab::Octocrab, org_name: &str, repo_name: &str) -> usize {
let mut page = octo
.pulls(org_name, repo_name)
.list()
// take all PRs -- open or closed
.state(octocrab::params::State::All)
// sort by date created
.sort(octocrab::params::pulls::Sort::Created)
// start with most recent
.direction(octocrab::params::Direction::Descending)
.per_page(255)
.send()
.await?;
let thirty_days_ago = Utc::now() - Duration::days(30);
let mut pr_count: usize = 0;
loop {
let in_last_thirty_days = page
.items
.iter()
// take while PRs have been created within the past thirty days
.take_while(|pr| pr.created_at > thirty_days_ago)
.count();
pr_count += in_last_thirty_days;
if in_last_thirty_days < page.items.len() {
// No need to visit the next page.
break;
}
if let Some(p) = octo.get_page(&page.next).await? {
page = p;
} else {
break;
}
}
pr_count
}
Couldn't find any method to get a single repository.
Would a octocrab.repos("owner", "repo").get()
method make sense?
If so and no one else is working on this, I can open a PR for it.
edit: I can reproduce this with older version as well now. I'm thoroughly confused and would appreciate any advice.
With current git, the following code results in thread 'main' has overflowed its stack
.
octocrab::instance()
.pulls("XAMPPRocky", "octocrab")
.get(129u64)
.await?;
I have reduced this to
let repo_json = r#"{ "user": { }, }"#;
let pr_deserialized: PullRequest = serde_json::from_str(repo_json).unwrap();
Deserializing a User is fine, it's just the User in the PullRequest (note the additional {}
around user
) that reproduces the problem.
edit: I now cannot repro this anymore with the snippet above, but rather this makes it crash now.
let repo_json = r#"{
"head": {
"repo": {
}
}
}
"#;
let pr_deserialized: PullRequest = serde_json::from_str(repo_json).unwrap();
Currently Page only has next and previous fields, but GitHub will also at times give you the first and last page in a paginated response. On top of that it would be nice if it also had a method that gave you the total number of pages if last is present.
https://developer.github.com/v3/guides/traversing-with-pagination/
Currently it up to the user to properly rate limit their application, it would be nice to provide the option to have octocrab
handle that.
I'm working with a GitHub App and authenticating as an installation, and I accidentally attempted to issue a POST request to a relative URI with _post
which requires an absolute URI.
That gave me this pretty useless error:
The application panicked (crashed).
Message: called `Option::unwrap()` on a `None` value
Location: /home/work/Projects/octocrab/src/lib.rs:824
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ BACKTRACE โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โฎ 7 frames hidden โฎ
8: core::panicking::panic::hcb81dec512b2768f
at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/panicking.rs:50
9: core::option::Option<T>::unwrap::h05db6a24d1ae163f
at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/option.rs:735
10: octocrab::Octocrab::execute::{{closure}}::h74b691434c0355f6
at /home/work/Projects/octocrab/src/lib.rs:824
822 โ }
823 โ AuthState::Installation { ref token, .. } => {
824 > retry_request = Some(request.try_clone().unwrap());
825 โ let token = if let Some(token) = token.get() {
826 โ token
11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll::ha56f78f2638f2d36
at /rustc/59eed8a2aac0230a8b53e89d4e99d55912ba6b35/library/core/src/future/mod.rs:80
12: octocrab::Octocrab::_post::{{closure}}::hf74689ec6e93cc37
at /home/work/Projects/octocrab/src/lib.rs:640
638 โ }
639 โ
640 > self.execute(request).await
641 โ }
642 โ
The problem is that this line:
retry_request = Some(request.try_clone().unwrap());
Fails to clone request
because it is holding an Err
, making try_clone()
return None
and then panic because of unwrap()
.
Output of dbg!(&request)
:
[/home/work/Projects/octocrab/src/lib.rs:814] &request = RequestBuilder {
error: reqwest::Error {
kind: Builder,
source: RelativeUrlWithoutBase,
},
}
I'm not sure what the best way to fix this is.
I want to use sqlx, octocrab and sqlxmq in a project.
Octocrab seems to have a tokio 0.2 dependency, and sqlx a tokio 1.x dependency. So I need to run sqlx with async std not tokio. But sqlxmq has a dependency on sqlx-tokio 1.x and sqlx can't run in two modes, so I would need to run the project sqlx also on tokio which then does not work with octocrab.
Is my assumption even right that Octocrab works with tokio 0.2?
Is there a way for Octocrab to work with async-std? Or with Tokio 1.x?
Hi,
I was working with some code where I was taking organization-wide webhook requests for all types of events, and I was trying to take advantage of octocrab
's existing event data types - but I quickly found out that there wasn't a simple way to deserialize them based on the X-GitHub-Event
header sent in webhook requests, and also that the types weren't compatible with the actual payloads.
What are these types for? Are they older payloads or are they for something else?
Do you have any recommendation on how to upload binaries to a release?
Currently octocrab
requires either using not authorization or providing a authorised token before, there should also be support for other forms authorization such as OAuth and GitHub App.
(Hi, I've looked around for a support channel or any way to ask questions but didn't find any)
From the documentation I can't find a way to read commit logs for a branch/repo, is there any?
As far as I can see the doc-cfg crate is being used in exactly 1 place, but it's a crate that has seen 0 activity in almost 2 years and pulls in multiple severely outdated crates that are duplicated with more recent versions that are brought in by other dependencies (eg proc-macro2 etc)
The file models.rs
is getting quite big, so I'd like to split it into smaller sub-modules.
What would be the best structure ? In thinking about
lib
โ issues
โ โ api
โ โ models
โ โ params
โ orgs
โ โ api
โ โ models
โ โ params
โ pulls
โ โ api
โ โ models
โ โ params
โ โฆ
and
lib
โ api
โ โ issues
โ โ orgs
โ โ pulls
โ โ โฆ
โ models
โ โ issues
โ โ orgs
โ โ pulls
โ โ โฆ
โ params
โ issues
โ orgs
โ pulls
โ โฆ
An issue we have immediately run into is retries and tracing:
Considering that octocrab
is using reqwest
as its HTTP client, would you be interested in adding support for client middlewares using reqwest-middleware
?
We'd be happy to open a PR in this direction.
list_tags() returns a page of models::repos::Tag, but then Tag model contains just private fields so it is not possible to fetch tag names from there.
In our github enterprise installation we have domain like https://repository.company.com/ and no other domains.
API is available under URI https://repository.company.com/api/v3/
There is no way to tell octocrab to use this URI as prefix for API it always strip down API URI to https://repository.company.com
Right now I can use only low level octocrab API where I have to provide exact URI manually
octointance.get("https://repository.company.com/api/v3/search/code", Some(¶ms))
I get an error when attempting to install this package from cargo:
error: failed to select a version for the requirement `arc-swap = "^0.4.6"`
candidate versions found which didn't match: 1.1.0, 0.4.1, 0.4.0, ...
location searched: crates.io index
required by package `octocrab v0.8.1`
Looks like arc-swap 0.4.6 and 0.4.7 were yanked due to a soundness issue. Also looks like this project has already been updated to ^1.0.0 (which was also yanked, but 1.1.0 should be compatible?) and just needs to be re-released.
As a workaround I'm going to use a git dependency for now. Thanks!
Currently there's a lot of boilerplate in octocrab
because of the builder pattern requires a lot of it to work properly, however there's no reason other than time and effort to replace the boilerplate with a procedural macro that generates the builder pattern code from the struct
itself.
Thanks again for the crate!
I'm looking at adding an extension to cover the events
API. I need to send custom headers (if-none-match
) so it seemed using execute was the right thing to use inside the extension trait. However, this takes a RequestBuilder
and it looks like the only way to get a RequestBuilder
in reqwest
is to build one from a client. The Octocrab
client
field is private so it's not accessible from a trait outside its own crate, I would have to create my own client to get a RequestBuilder
.
Maybe I'm missing something ๐ค what is the intended way to get a RequestBuilder
to use with execute
?
Would it make sense to add a releases
endpoint to easily query for releases of a repository and loop through them with an iterator?
Would love that, as that would make updating software from github releases much easier.
I'd like to add tests against samples in the GitHub Docs reference for structs in the ยดmodelsยด module.
These samples are often hunderds of lines long, so I'm not sure where to put these tests.
I just stumbled over this project when looking for a Rust client for GitHub APIs. And I really liked what I saw.
What bothered me though, was that the project seemed to be kind of dead:
Checking the tags, I quickly figured out, that this is just a lack up updated release records.
I would suggest to:
Title says all :) Because of that I went directly to installing octocrab from the git repo instead of from crates.io, before I realized there are newer releases there.
I have an app that I'm trying to update to those versions, but as long as octocrab requires reqwest 0.10.10
I get this error:
thread 'main' panicked at 'not currently running on the Tokio runtime.', /home/autarch/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-0.2.24/src/runtime/handle.rs:118:28
See this snippet:
Lines 353 to 357 in 06b4a25
NB: copy-pasting late at night might not always go well :D
I attempted to use your example code to get a list of the user notifications but it seems to be unable to decode the IDs. If I curl the API each ID is a string, whereas in the code the IDs are u64 and Serde doesn't seem to convert it.
Hi,
I am trying to use this crate in my project alongside rocket-rs, only there seems to be an issue with the dependencies
stdout : Updating crates.io index
error: failed to select a version for `httparse`.
... required by package `hyperx v1.3.0`
... which satisfies dependency `hyperx = "^1.3.0"` of package `octocrab v0.12.0`
... which satisfies dependency `octocrab = "^0.12.0"` of package `version-summarizer v0.1.0 (/home/infrandomness/Documents/Dev/Rust/version-summarizer)`
versions that meet the requirements `>=1.0, <1.4` are: 1.3.6, 1.3.5, 1.3.4, 1.3.3, 1.3.2, 1.3.1, 1.3.0, 1.2.5, 1.2.4, 1.2.3, 1.2.2, 1.2.1, 1.2.0, 1.1.2, 1.1.1, 1.1.0, 1.0.0
all possible versions conflict with previously selected packages.
previously selected package `httparse v1.4.0`
... which satisfies dependency `httparse = "^1.4"` of package `hyper v0.14.9`
... which satisfies dependency `hyper = "^0.14.2"` of package `hyper-tls v0.5.0`
... which satisfies dependency `hyper-tls = "^0.5"` of package `reqwest v0.11.4`
... which satisfies dependency `reqwest = "^0.11.3"` of package `octocrab v0.12.0`
... which satisfies dependency `octocrab = "^0.12.0"` of package `version-summarizer v0.1.0 (/home/infrandomness/Documents/Dev/Rust/version-summarizer)`
failed to select a version for `httparse` which could resolve this conflict
This happens when I have both rocket (latest version as of today) and octocrab
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.