Skip to content

Conversation

frcroth
Copy link
Contributor

@frcroth frcroth commented Aug 13, 2025

I always had "No pull request found" and wanted a more useful error.

@frcroth frcroth requested a review from fm3 August 13, 2025 09:54
Copy link
Contributor

coderabbitai bot commented Aug 13, 2025

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

Refines get_pr_number_from_gh in tools/create-changelog-entry.py to catch subprocess.CalledProcessError as e, inspect e.stderr for HTTP 401 or Bad credentials, and print an auth-specific message advising gh auth login; other CalledProcessError cases keep the generic "No pull request found" message. Also changes a section header in unreleased_changes/8854.md from "### Added" to "### Changed".

Changes

Cohort / File(s) Summary of Changes
Changelog tooling
tools/create-changelog-entry.py
Bind CalledProcessError as e and inspect e.stderr in get_pr_number_from_gh; if it contains HTTP 401 or Bad credentials print an authentication message advising gh auth login and note no PR found; otherwise preserve generic "No pull request found" message. Return behavior unchanged.
Unreleased changelog
unreleased_changes/8854.md
Change header from ### Added to ### Changed; content of the bullet remains the same.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~7 minutes

Possibly related PRs

Suggested reviewers

  • normanrz
  • fm3

Poem

I sniff the stderr, twitch my ear,
"Bad credentials" whispers clear.
Hop to auth, then try once more —
PRs will find the branching door. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c312a72 and 1a3aa3f.

📒 Files selected for processing (2)
  • tools/create-changelog-entry.py (1 hunks)
  • unreleased_changes/8854.md (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch improve-error-in-changelog-tool

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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

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

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@frcroth frcroth enabled auto-merge (squash) August 13, 2025 09:57
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

🧹 Nitpick comments (1)
tools/create-changelog-entry.py (1)

41-43: Nit: Print CLI-not-found message to stderr for consistency.

For consistency with error conditions above and to keep stdout clean for normal output, print the "gh not found" message to stderr.

Outside the changed hunk, update the print to:

print("⚠️  GitHub CLI (`gh`) not found. You can install it from https://cli.github.com/", file=sys.stderr)
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0fc8167 and c312a72.

📒 Files selected for processing (1)
  • tools/create-changelog-entry.py (1 hunks)
⏰ 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). (3)
  • GitHub Check: backend-tests
  • GitHub Check: build-smoketest-push
  • GitHub Check: frontend-tests

Comment on lines 44 to 48
except subprocess.CalledProcessError as e:
if "Bad credentials" in e.stderr:
print("⚠️ You are not authenticated with GitHub (Run 'gh auth login'). No pull request found.")
else:
print("⚠️ No pull request found for the current branch.")
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Broaden auth error detection and print errors to stderr (more accurate guidance).

The GH CLI commonly reports unauth scenarios as "gh: Not logged in" or "HTTP 401: Unauthorized", not only "Bad credentials". Also, mixing an auth warning with "No pull request found" is confusing. Recommend:

  • Case-insensitive matching against several common auth phrases.
  • Fallback to e.output if stderr is empty.
  • Print diagnostics to stderr.

Apply this diff:

-except subprocess.CalledProcessError as e:
-    if "Bad credentials" in e.stderr:
-        print("⚠️  You are not authenticated with GitHub (Run 'gh auth login'). No pull request found.")
-    else:
-        print("⚠️  No pull request found for the current branch.")
+except subprocess.CalledProcessError as e:
+    msg = (e.stderr or e.output or "").lower()
+    if any(s in msg for s in [
+        "bad credentials",
+        "not logged in",
+        "unauthorized",
+        "authentication failed",
+        "forbidden",   # e.g., SAML enforcement/insufficient scopes
+    ]):
+        print("⚠️  You are not authenticated with GitHub. Run 'gh auth status' and 'gh auth login'.", file=sys.stderr)
+    else:
+        print("⚠️  No pull request found for the current branch.", file=sys.stderr)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
except subprocess.CalledProcessError as e:
if "Bad credentials" in e.stderr:
print("⚠️ You are not authenticated with GitHub (Run 'gh auth login'). No pull request found.")
else:
print("⚠️ No pull request found for the current branch.")
except subprocess.CalledProcessError as e:
msg = (e.stderr or e.output or "").lower()
if any(s in msg for s in [
"bad credentials",
"not logged in",
"unauthorized",
"authentication failed",
"forbidden", # e.g., SAML enforcement/insufficient scopes
]):
print(
"⚠️ You are not authenticated with GitHub. "
"Run 'gh auth status' and 'gh auth login'.",
file=sys.stderr,
)
else:
print(
"⚠️ No pull request found for the current branch.",
file=sys.stderr,
)

@frcroth frcroth disabled auto-merge August 13, 2025 09:59
@frcroth frcroth enabled auto-merge (squash) August 13, 2025 10:00
@frcroth frcroth merged commit f507836 into master Aug 13, 2025
4 checks passed
@frcroth frcroth deleted the improve-error-in-changelog-tool branch August 13, 2025 10:07
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