Skip to content

bad title test#216

Merged
exploreriii merged 1 commit into
mainfrom
bot-clean-recovery
Feb 24, 2026
Merged

bad title test#216
exploreriii merged 1 commit into
mainfrom
bot-clean-recovery

Conversation

@exploreriii

Copy link
Copy Markdown
Owner

Description:

Related issue(s):

Fixes #

Notes for reviewer:

Checklist

  • Documented (Code comments, README, etc.)
  • Tested (unit, integration, etc.)

Signed-off-by: Ashhar Ahmad Khan <145142826+AshharAhmadKhan@users.noreply.github.com>
@exploreriii
exploreriii marked this pull request as ready for review February 24, 2026 18:39
@github-actions

Copy link
Copy Markdown
Hi @exploreriii, this is **LinkBot** 👋

Linking pull requests to issues helps us significantly with reviewing pull requests and keeping the repository healthy.

🚨 This pull request does not have an issue linked.

Please link an issue using the following format:

Fixes #123

📖 Guide:
docs/sdk_developers/how_to_link_issues.md

If no issue exists yet, please create one:
docs/sdk_developers/creating_issues.md

Thanks!

@exploreriii
exploreriii merged commit 81a351a into main Feb 24, 2026
19 of 20 checks passed
@coderabbitai

coderabbitai Bot commented Feb 24, 2026

Copy link
Copy Markdown

Walkthrough

Introduces a new GitHub bot script to automate PR title validation against conventional-commit patterns and provide guidance via PR comments. Updates the corresponding workflow to enable dry-run mode, add new permissions, and trigger bot comment logic on validation failure.

Changes

Cohort / File(s) Summary
PR Title Validation Bot
.github/scripts/bot-conventional-pr-title.js
New module with three exported functions: suggestConventionalType() maps PR title keywords to conventional-commit types; formatMessage() generates Markdown bot guidance; run() orchestrates GitHub API interactions including comment pagination, comment update/creation detection, and robust error handling with special handling for fork PR permission errors.
Workflow Configuration
.github/workflows/pr-check-title.yml
Expanded workflow with configurable dry-run mode input for workflow_dispatch, added permissions for pull-requests and contents, explicit step ID for title check action, and conditional failure steps that checkout the repo and invoke the bot script via GitHub Script to post PR guidance.

Sequence Diagram

sequenceDiagram
    participant WF as Workflow
    participant Bot as Bot Script
    participant GH as GitHub API
    participant PR as PR

    WF->>WF: Trigger on pull_request event
    WF->>Bot: run({github, context, prNumber, prTitle})
    activate Bot
    
    Bot->>Bot: suggestConventionalType(prTitle)
    Note over Bot: Parse title against<br/>conventional patterns
    Bot->>Bot: Generate suggested type
    
    Bot->>GH: Fetch PR comments<br/>(paginated, up to 500)
    activate GH
    GH-->>Bot: Return comment list
    deactivate GH
    
    Bot->>Bot: Search for existing<br/>bot comment by marker
    
    alt Bot comment exists
        Bot->>GH: Update existing comment
    else Bot comment not found
        Bot->>GH: Create new comment
    end
    
    activate GH
    GH->>PR: Update/Create comment
    GH-->>Bot: Success or error
    deactivate GH
    
    Bot->>Bot: formatMessage(title, type, prNumber)
    Note over Bot: Build Markdown<br/>guidance message
    
    deactivate Bot
    Bot-->>WF: Return status
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~35 minutes

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (2 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'bad title test' is vague and generic, using non-descriptive terms that do not convey meaningful information about the changeset. Provide a descriptive title that clearly summarizes the main change, such as 'Add conventional PR title bot for automated feedback' or similar.
Description check ❓ Inconclusive The description is an empty template with no content provided; it contains only unchecked checkboxes and placeholder sections without any actual information about the changes. Fill in the description template with details about what this PR does, why it's needed, and any related issues or testing notes.
✅ Passed checks (1 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bot-clean-recovery

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4


ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a7a2182 and f055f87.

📒 Files selected for processing (3)
  • .github/scripts/bot-conventional-pr-title.js
  • .github/workflows/pr-check-title.yml
  • CHANGELOG.md

Comment on lines +131 to +136
function escapeForMarkdown(text) {
return text
.replace(/```/g, "'''")
.replace(/\r?\n|\r/g, ' ')
.trim();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

escapedTitle doesn't strip newlines, which can break the suggested CLI command.

escapeForMarkdown strips newlines from safeTitle, but the shell-escaped escapedTitle (line 164) is derived from the raw currentTitle and retains embedded newlines. A PR title containing \n would produce a broken multi-line gh pr edit command in the instructions.

Proposed fix — strip newlines before shell-escaping
 function formatMessage(currentTitle, suggestedType, prNumber) {
-  // Escape shell-sensitive characters for the CLI example
-  const escapedTitle = currentTitle.replace(/["$`\\]/g, '\\$&');
   const safeTitle = escapeForMarkdown(currentTitle);
+  // Escape shell-sensitive characters for the CLI example (use safeTitle which already has newlines stripped)
+  const escapedTitle = safeTitle.replace(/["$`\\]/g, '\\$&');

   return composeBotMessage({

Also applies to: 162-164

Comment on lines +214 to +243
// Fetch comments with pagination and early exit
let commentCount = 0;
let page = 1;
let botComment = null;

while (commentCount < MAX_COMMENTS_TO_FETCH && !botComment) {
const response = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
per_page: 100,
page: page
});

commentCount += response.data.length;

// Check if we found the bot comment
botComment = response.data.find(comment =>
comment.body && comment.body.includes(COMMENT_IDENTIFIER)
);

// Exit if no more pages or found the comment
if (response.data.length < 100 || botComment) {
break;
}

page++;
}

console.log(`[Bot] Fetched ${commentCount} comments across ${page} page(s)`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Pagination is well-bounded with early exit — consider filtering by bot author.

The pagination logic is correct with a 500-comment upper bound and early termination. One minor improvement: filter comments by the bot's user login (or at minimum check comment.user.type === 'Bot') to avoid matching the marker in a non-bot comment.

Comment on lines +6 to +18
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Run without posting comments'
type: boolean
default: true
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

synchronize trigger type is unnecessary for a title-check workflow.

The synchronize event fires when new commits are pushed to the PR branch, but that doesn't change the PR title. This causes redundant workflow runs on every push. Only opened, reopened, and edited are relevant for title validation.

Proposed fix — remove synchronize
   pull_request_target:
     types:
       - opened
       - reopened
       - edited
-      - synchronize
📝 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
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Run without posting comments'
type: boolean
default: true
pull_request_target:
types:
- opened
- reopened
- edited
- synchronize
on:
workflow_dispatch:
inputs:
dry_run:
description: 'Run without posting comments'
type: boolean
default: true
pull_request_target:
types:
- opened
- reopened
- edited
🧰 Tools
🪛 YAMLlint (1.38.0)

[warning] 6-6: truthy value should be one of [false, true]

(truthy)

Comment on lines +64 to +82
script: |
const script = require('./.github/scripts/bot-conventional-pr-title.js');

if (!context.payload.pull_request) {
console.log('[Bot] No pull_request in context, skipping');
return;
}

const isDryRun = context.eventName === 'workflow_dispatch'
? (context.payload.inputs?.dry_run === 'true')
: false;

await script.run({
github: github,
context: context,
prNumber: context.payload.pull_request.number,
prTitle: context.payload.pull_request.title,
dryRun: isDryRun
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Inline script is appropriately minimal — orchestration only.

The YAML delegates all logic to the external script, with the inline block handling only payload validation and parameter passing. This aligns well with the guideline to keep business logic in .github/scripts/.

One note: when triggered via workflow_dispatch, context.payload.pull_request will be undefined, so the guard at line 67 will always exit early — making the dry_run input effectively untestable through workflow_dispatch alone. Consider documenting this or adding a pr_number input for manual testing.

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