Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

create_workflow_dispatch failed with GitHubError #622

Open
siisee11 opened this issue Apr 2, 2024 · 4 comments
Open

create_workflow_dispatch failed with GitHubError #622

siisee11 opened this issue Apr 2, 2024 · 4 comments

Comments

@siisee11
Copy link

siisee11 commented Apr 2, 2024

   octocrab
        .actions()
        .create_workflow_dispatch("owner", "repo", workflow_id, "develop")
        .send()
        .await?;

create_workflow_dispatch failed with GitHubError

Error message is Invalid request.\n\nFor 'properties/inputs', nil is not an object

@siisee11
Copy link
Author

siisee11 commented Apr 2, 2024

https://github.com/XAMPPRocky/octocrab/blob/505befed0e40faa15321772009a814f6f510f614/src/models/workflows.rs#L154C1-L159C2

#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, Default)]
#[non_exhaustive]
pub struct WorkflowDispatch {
    pub r#ref: String,
    pub inputs: serde_json::Value,
}

Maybe should be changed to

    pub ref: String,

@XAMPPRocky
Copy link
Owner

Thank you for your issue!

Maybe should be changed to

   pub ref: String,

Not possible, ref is a keyword in Rust, so it has to be r#ref. Are you sure that's what's causing the issue and not that inputs is Value::Null instead of Value::Object?

@aarchangel64
Copy link

I'm also having this issue. I was able to fix it by adding inputs as a workaround, but it's not ideal to need this:

   octocrab
        .actions()
        .create_workflow_dispatch("owner", "repo", workflow_id, "develop")
        .inputs(serde_json::json!({}))
        .send()
        .await?;

@siisee11
Copy link
Author

@XAMPPRocky Sorry, I didn't see the notification earlier.
It's been a while, so I don't remember exactly what the issue was.
I'm not very familiar with Rust, but I'll share the workaround I came up with.

let route = format!(
       "https://api.github.com/repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches",
       owner = owner,
       repo = repo_name,
       workflow_id = workflow_id
   );

let res = octocrab
       ._post(route, Some(&serde_json::json!({ "ref": "develop"})))
       .await?;

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

No branches or pull requests

3 participants