Skip to content

Make take issue comment to use curl #5937

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

Merged
merged 2 commits into from
Jul 10, 2025

Conversation

ShaharNaveh
Copy link
Contributor

@ShaharNaveh ShaharNaveh commented Jul 10, 2025

After some debugging I got to scikit-learn/scikit-learn#29395 (comment)

Which, after running:

gh api graphql -f query='query($endCursor:String){repository(owner:"RustPython",name:"RustPython"){assignableUsers(first:100,after:$endCursor){nodes{login}pageInfo{endCursor,hasNextPage}}}}' --paginate --jq '.data.repository.assignableUsers.nodes[].login'

Returned:

arihant2math
BenLewis-Seequent
charliermarsh
coolreader18
cthulahoops
DimitrisJim
fanninpm
MichaReiser
mireille-raad
OddBloke
palaviv
qingshi163
shinglyu
windelbouwman
youknowone

So, I've switched it to use curl. now it should work for non maintainers as well

Summary by CodeRabbit

  • Chores
    • Updated the workflow for assigning issues based on comment commands to use a direct API call for improved reliability.

Copy link
Contributor

coderabbitai bot commented Jul 10, 2025

Walkthrough

The workflow for assigning an issue via a comment command in the GitHub Actions configuration was updated. The assignment step now uses a direct REST API call with curl instead of the GitHub CLI. Environment variable handling and parameter passing were adjusted to fit the new approach, while job permissions and structure remain unchanged.

Changes

File(s) Change Summary
.github/workflows/comment-commands.yml Replaced GitHub CLI-based issue assignment with a direct REST API call using curl.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant GitHub Actions
    participant GitHub API

    User->>GitHub Actions: Comment triggers workflow
    GitHub Actions->>GitHub API: POST /repos/{owner}/{repo}/issues/{issue_number}/assignees (assign issue)
    GitHub API-->>GitHub Actions: Assignment result
Loading

Possibly related PRs

Suggested reviewers

  • youknowone

Poem

A comment appears, a bunny takes note,
Assigning an issue, now via a curl quote.
No more CLI hops, just a RESTful leap,
The workflow is nimble, the API deep.
With every command, the garden grows neat—
🐇✨ Code carrots for all, a GitHub treat!


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: .coderabbit.yml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 089c39f and 624cd4c.

📒 Files selected for processing (1)
  • .github/workflows/comment-commands.yml (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: ShaharNaveh
PR: RustPython/RustPython#5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.304Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.
.github/workflows/comment-commands.yml (1)
Learnt from: ShaharNaveh
PR: RustPython/RustPython#5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.304Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.
🪛 actionlint (1.7.7)
.github/workflows/comment-commands.yml

21-21: could not parse as YAML: yaml: line 21: mapping values are not allowed in this context

(syntax-check)

🪛 YAMLlint (1.37.1)
.github/workflows/comment-commands.yml

[error] 21-21: syntax error: mapping values are not allowed here

(syntax)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (11)
  • GitHub Check: Run snippets and cpython tests on wasm-wasi
  • GitHub Check: Run rust tests (macos-latest)
  • GitHub Check: Run tests under miri
  • GitHub Check: Check Rust code with rustfmt and clippy
  • GitHub Check: Check the WASM package and demo
  • GitHub Check: Run snippets and cpython tests (ubuntu-latest)
  • GitHub Check: Run rust tests (windows-latest)
  • GitHub Check: Run snippets and cpython tests (windows-latest)
  • GitHub Check: Run rust tests (ubuntu-latest)
  • GitHub Check: Ensure compilation on various targets
  • GitHub Check: Run snippets and cpython tests (macos-latest)

Comment on lines 18 to +23
steps:
- run: gh issue edit "${{ env.ISSUE_NUMBER }}" --add-assignee "@${{ env.USER_LOGIN }}"
env:
ISSUE_NUMBER: ${{ github.event.issue.number }}
USER_LOGIN: ${{ github.event.comment.user.login }}
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
# Using REST API and not `gh issue edit`. https://github.com/cli/cli/issues/6235#issuecomment-1243487651
- run: curl \
-H "Authorization: token ${{ github.token }}" \
-d '{"assignees": ["${{ github.event.comment.user.login }}"]}' \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
Copy link
Contributor

@coderabbitai coderabbitai bot Jul 10, 2025

Choose a reason for hiding this comment

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

⚠️ Potential issue

Workflow fails to parse – convert the multi-line run script to a block scalar.

actionlint / yamllint correctly report a YAML syntax error because the multi-line curl command is written as a plain scalar; the embedded : in the header line is parsed as a new mapping key.
The job will never start.

-      - run: curl \
-          -H "Authorization: token ${{ github.token }}" \
-          -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' \
-          https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
+      - run: |
+          curl -sS \
+            -H "Authorization: token ${{ github.token }}" \
+            -H "Content-Type: application/json" \
+            -d "{\"assignees\": [\"${{ github.event.comment.user.login }}\"]}" \
+            "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees"

Block-scalar (|) formatting eliminates the syntax error and makes the script easier to read.
Adding -H "Content-Type: application/json" and quoting the URL are optional polish but keep the command self-contained.

🧰 Tools
🪛 actionlint (1.7.7)

21-21: could not parse as YAML: yaml: line 21: mapping values are not allowed in this context

(syntax-check)

🪛 YAMLlint (1.37.1)

[error] 21-21: syntax error: mapping values are not allowed here

(syntax)

🤖 Prompt for AI Agents
In .github/workflows/comment-commands.yml around lines 18 to 23, the multi-line
curl command under the run step is written as a plain scalar causing YAML syntax
errors due to unescaped colons. Convert the multi-line run script to use a block
scalar (|) to properly format the command as a literal block. Optionally, add
the header "Content-Type: application/json" and quote the URL string to improve
clarity and completeness.

Copy link
Contributor Author

@ShaharNaveh ShaharNaveh Jul 11, 2025

Choose a reason for hiding this comment

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

@coderabbitai can you open a PR with those changes?

Copy link
Contributor

Choose a reason for hiding this comment

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

@ShaharNaveh I'll plan the code changes to fix the YAML syntax error in the workflow file. Another agent will execute these changes and create the PR for you.

Task: Fix YAML syntax error in comment-commands.yml

  • Convert multi-line curl command to use block scalar format
  • Add proper escaping and formatting
  • Include Content-Type header and quote URL for completeness

The changes will fix the YAML parsing error by using proper block scalar formatting, and I've included the Content-Type header and URL quoting for better clarity and completeness as suggested in my previous comment.


🧠 Learnings used
Learnt from: ShaharNaveh
PR: RustPython/RustPython#5932
File: .github/workflows/comment-commands.yml:18-24
Timestamp: 2025-07-10T10:08:43.304Z
Learning: In GitHub Actions workflows for the RustPython project, the maintainer ShaharNaveh prefers to keep workflows simple and doesn't mind if steps fail when the desired state is already achieved (e.g., user already assigned to an issue). Avoid suggesting complex error handling for edge cases they don't consider problematic.

⏳ Preparing changes...

Copy link
Contributor

Choose a reason for hiding this comment

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

A summary of the changes CodeRabbit can apply:

  • Fix the YAML syntax error in the GitHub Actions workflow by converting the multi-line curl command to block scalar format with proper indentation and escaping, ensuring correct parsing of the Authorization header.
  • ✅ Create PR with these edits
  • 📌 Create commit in current branch
  • 📋 Get copyable edits

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@coderabbitai Create PR with these edits

Copy link
Contributor

Choose a reason for hiding this comment

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

Caution

CodeRabbit has failed to create the PR to execute your edits.

Copy link
Contributor Author

@ShaharNaveh ShaharNaveh Jul 11, 2025

Choose a reason for hiding this comment

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

@coderabbitai get me a copyable edit

Copy link
Contributor

Choose a reason for hiding this comment

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

Here are the copyable edits based on the planned changes:

Copyable Edits

.github/workflows/comment-commands.yml

@@ -17,7 +17,9 @@
 
    steps:
      # Using REST API and not `gh issue edit`. https://github.com/cli/cli/issues/6235#issuecomment-1243487651
-     - run: curl \
-         -H "Authorization: token ${{ github.token }}" \
-         -d '{"assignees": ["${{ github.event.comment.user.login }}"]}' \
-         https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees
+     - run: |
+         curl -sS \
+           -H "Authorization: token ${{ github.token }}" \
+           -H "Content-Type: application/json" \
+           -d "{"assignees": ["${{ github.event.comment.user.login }}"]}" \
+           "https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/assignees"
  • ✅ Create PR with these edits
  • 📌 Create commit in current branch

@youknowone youknowone merged commit 38837e5 into RustPython:main Jul 10, 2025
12 checks passed
@ShaharNaveh ShaharNaveh deleted the github-actions-take branch July 11, 2025 09:27
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