Skip to content
This repository was archived by the owner on Aug 10, 2026. It is now read-only.

Import YAML helpers for repository governance - #1

Merged
1 commit merged into
mainfrom
upload-repo-governance-1775832405577
Apr 10, 2026
Merged

Import YAML helpers for repository governance#1
1 commit merged into
mainfrom
upload-repo-governance-1775832405577

Conversation

@ghost

@ghost ghost commented Apr 10, 2026

Copy link
Copy Markdown

This pull request introduces necessary configuration files for repository management.

  • Chores
    • Configured automated dependency monitoring with weekly checks and auto-merge for minor/patch updates.
    • Added security scanning workflows using CodeQL and OpenSSF Scorecard for continuous code analysis.
    • Enabled automated code quality and linting checks on pull requests.
    • Introduced standardized templates for bug reports and feature requests to improve contribution workflow.
    • Added GitHub funding links and configured label synchronization for improved repository management.

Summary by CodeRabbit

  • New Features

    • Added structured issue templates guiding users to report bugs and request features
    • Implemented automated security scanning on pull requests and scheduled runs
    • Enabled automated dependency updates with smart merging for patch/minor version upgrades
  • Chores

    • Added automated linting validation for pull requests
    • Configured comprehensive GitHub labels for issue organization and triage
    • Established pull request template with development checklist

…tory management.

* **Chores**
  * Configured automated dependency monitoring with weekly checks and auto-merge for minor/patch updates.
  * Added security scanning workflows using CodeQL and OpenSSF Scorecard for continuous code analysis.
  * Enabled automated code quality and linting checks on pull requests.
  * Introduced standardized templates for bug reports and feature requests to improve contribution workflow.
  * Added GitHub funding links and configured label synchronization for improved repository management.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Apr 10, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

This PR establishes comprehensive GitHub repository automation infrastructure, including structured issue and pull request templates, dependency management configuration, GitHub Actions workflows for CI/CD and security scanning, a label taxonomy, and a Python module that generates issues from AI-analyzed code changes.

Changes

Cohort / File(s) Summary
GitHub Configuration
.github/labels.yml, .github/dependabot.yml
Defines a 7-tier severity label system, type/classification labels, and workflow labels. Configures automated weekly dependency update checks for pip packages and GitHub Actions workflows with specific label tagging.
Issue & PR Templates
.github/ISSUE_TEMPLATE/bug_report.yml, .github/ISSUE_TEMPLATE/feature_request.yml, .github/pull_request_template.md
Introduces structured templates for bug reports (with environment/reproduction/behavior sections), feature requests (with problem/solution/alternatives sections), and pull requests (with type selection and development checklists).
GitHub Actions Workflows
.github/workflows/ai-issue.yml, .github/workflows/dependabot-auto-merge.yml, .github/workflows/label-sync.yml, .github/workflows/lint.yml, .github/workflows/sast.yml, .github/workflows/scorecard.yml
Adds six workflows: AI-based issue generation on push/PR events; automatic approval and merging of Dependabot patches (semver-patch/minor); label synchronization from .github/labels.yml; Node.js linting for PRs; CodeQL security analysis (Python/JavaScript matrix); and OpenSSF Scorecard scanning on schedule/main pushes.
AI Issue Generation Module
trigger action/trigger_action.py
Implements GitHub Actions entrypoint that analyzes code changes (from push or PR events), calls an external AI model with change context, generates issue payloads with severity mapping and deduplication, creates GitHub issues, and posts PR comments linking to created issues.

Sequence Diagram

sequenceDiagram
    participant GA as GitHub Actions<br/>(ai-issue.yml)
    participant TA as trigger_action.py
    participant GH as GitHub API
    participant Model as AI Model API
    participant Issue as GitHub Issue

    GA->>TA: trigger (push/PR event,<br/>env vars)
    TA->>GH: fetch commit/PR details
    GH-->>TA: file patches, author, message
    TA->>TA: extract dedup key,<br/>labels, file context
    TA->>GH: scan existing issues<br/>(dedup check)
    GH-->>TA: issue list
    alt diff too small or duplicate
        TA-->>GA: skip
    else proceed
        TA->>TA: build prompt<br/>(role, severity scale,<br/>files, diff)
        TA->>Model: call with prompt<br/>(retry/backoff)
        Model-->>TA: issue payload + labels
        TA->>TA: map severity to label,<br/>build permalink
        TA->>GH: create issue
        GH-->>Issue: issue created
        Issue-->>TA: issue number
        alt pull_request event
            TA->>GH: post PR comment<br/>(link to issue)
        end
    end
Loading

Estimated Code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related issues

  • The addition of lint.yml (Node.js linting workflow) and sast.yml (CodeQL security scanning) directly addresses the objectives of establishing automated code quality and security scanning infrastructure, overlapping with the retrieved issue's scope of adding lint and CodeQL/bandit workflows.

Poem

🐰 Workflows bloom like carrots in spring,
Labels organized in neat little rings,
AI issues generated with AI flair,
GitHub automation floating in the air!
Dependencies merged, security scanned tight,
This rabbit's code garden shines so bright! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title 'Import YAML helpers for repository governance' does not accurately describe the main changes, which are comprehensive repository governance and CI/CD configuration, not just YAML helper imports. Consider a more descriptive title such as 'Add repository governance and CI/CD workflows' or 'Configure automated dependency management and security scanning' to better reflect the scope of changes.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch upload-repo-governance-1775832405577

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: 5

🧹 Nitpick comments (2)
.github/pull_request_template.md (1)

12-16: Testing checklist items are project-specific.

The testing section references process_event.py and "Gemini API" which may not apply to all PRs in this repository. Consider making these items more generic or adding a note that contributors should adjust based on the changes being made.

♻️ Suggested generic alternative
 ## Testing Performed
-- [ ] Local execution of `process_event.py`
-- [ ] Verified JSON output structure from Gemini API
-- [ ] Tested GitHub Action workflow trigger (dry-run)
+- [ ] Local testing completed
+- [ ] Relevant workflow/action tested (if applicable)
+- [ ] Integration points verified
 - [ ] Other: 
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/pull_request_template.md around lines 12 - 16, Update the "##
Testing Performed" section to use a generic, adaptable checklist: replace
specific items like `process_event.py` and "Gemini API" with neutral
placeholders or guidance (e.g., "Run relevant project tests / scripts", "Verify
API responses where applicable") and add a short note telling contributors to
adjust checklist items to match their PR changes; update the header block that
currently lists `process_event.py` and "Gemini API" so the template reads
generically and includes an "Other: (describe)" prompt for project-specific
checks.
.github/workflows/scorecard.yml (1)

30-35: Missing SARIF upload step to publish results to GitHub Security tab.

The workflow generates a SARIF file but doesn't upload it to GitHub's Security tab. The publish_results: true option publishes to the OpenSSF public dashboard, but you need an additional step to see findings in your repository's Security tab.

🔧 Proposed fix to add SARIF upload
       - name: Run analysis
         uses: ossf/scorecard-action@v2.4.3
         with:
           results_file: scorecard-results.sarif
           results_format: sarif
           publish_results: true
+
+      - name: Upload SARIF to GitHub Security
+        uses: github/codeql-action/upload-sarif@v3
+        with:
+          sarif_file: scorecard-results.sarif
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/scorecard.yml around lines 30 - 35, The workflow runs the
OSSF Scorecard action ("Run analysis" using ossf/scorecard-action@v2.4.3) and
writes scorecard-results.sarif but never uploads it to the repository Security
tab; add a follow-up step that uses the GitHub SARIF uploader (e.g.,
github/codeql-action/upload-sarif) to upload the artifact by specifying the same
results file (scorecard-results.sarif) so findings appear in the repo Security
tab and not just the public OpenSSF dashboard.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/dependabot.yml:
- Around line 7-9: The dependabot config references labels "python" and
"actions" that are not defined in your managed label set, causing Dependabot to
create default-styled labels; add label entries for name "python" (color 3572A5,
description "Python-related changes") and name "actions" (color 2088FF,
description "GitHub Actions workflow changes") to .github/labels.yml so they
match your taxonomy and prevent auto-created defaults.

In @.github/workflows/ai-issue.yml:
- Around line 26-49: The workflow currently checks out and executes PR-head code
(trigger_action.py) while exposing secrets (GH_MODELS_TOKEN, GITHUB_TOKEN);
change the job so it runs the analysis from a trusted ref instead of the PR
head: in the "Run AI Analysis" job (symbols: actions/checkout@v6,
trigger_action.py, GH_MODELS_TOKEN, GITHUB_TOKEN) checkout a known safe ref
(e.g., the PR base branch or a protected branch) by adding a checkout step with
ref: github.event.pull_request.base.ref (or a hardcoded main/prod ref) before
running the script, or switch the workflow to pull_request_target and ensure
checkout uses the base ref; do not pass repository secrets to any step that runs
code from the PR head.

In @.github/workflows/sast.yml:
- Around line 11-13: Move the top-level concurrency section into the job that
defines the matrix so the matrix context is available: remove the workflow-level
"concurrency" block and add an identical "concurrency:" block inside the job
definition that uses the matrix (the job that runs CodeQL), keeping "group:
codeql-${{ matrix.language }}" and "cancel-in-progress: false" so parallel
matrix runs deduplicate correctly using matrix.language.

In `@trigger` action/trigger_action.py:
- Around line 442-456: The retry loop in trigger_action.py (the for attempt in
range(retries) block that posts to ENDPOINT and calls
resp.raise_for_status()/json.loads(raw)) swallows failures and calls exit(0),
making CI/workflows report success even when requests/auth/JSON parsing fail;
change the final failure behavior to surface the error by either re-raising the
last exception or calling exit with a non-zero status (e.g., exit(1)), and
include the last exception message in the log before exiting so failures cause
the job to fail rather than silently succeeding.
- Around line 156-161: In build_permalink, the code currently prefers COMMIT_SHA
(which may be the synthetic merge SHA) and doesn't URL-encode filenames; change
the logic to use the PR head SHA when pr_ref is present (use pr_ref.head.sha as
the primary source, falling back to COMMIT_SHA or empty string) and URL-encode
the filename/path (e.g., via urllib.parse.quote) before interpolating into the
URL; update references in build_permalink to use the resolved sha and the
encoded filename while keeping repo_name and line as before.

---

Nitpick comments:
In @.github/pull_request_template.md:
- Around line 12-16: Update the "## Testing Performed" section to use a generic,
adaptable checklist: replace specific items like `process_event.py` and "Gemini
API" with neutral placeholders or guidance (e.g., "Run relevant project tests /
scripts", "Verify API responses where applicable") and add a short note telling
contributors to adjust checklist items to match their PR changes; update the
header block that currently lists `process_event.py` and "Gemini API" so the
template reads generically and includes an "Other: (describe)" prompt for
project-specific checks.

In @.github/workflows/scorecard.yml:
- Around line 30-35: The workflow runs the OSSF Scorecard action ("Run analysis"
using ossf/scorecard-action@v2.4.3) and writes scorecard-results.sarif but never
uploads it to the repository Security tab; add a follow-up step that uses the
GitHub SARIF uploader (e.g., github/codeql-action/upload-sarif) to upload the
artifact by specifying the same results file (scorecard-results.sarif) so
findings appear in the repo Security tab and not just the public OpenSSF
dashboard.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 6dcbbe3e-7950-470b-97a2-5badedcc476c

📥 Commits

Reviewing files that changed from the base of the PR and between bb760fb and a673f3c.

📒 Files selected for processing (12)
  • .github/ISSUE_TEMPLATE/bug_report.yml
  • .github/ISSUE_TEMPLATE/feature_request.yml
  • .github/dependabot.yml
  • .github/labels.yml
  • .github/pull_request_template.md
  • .github/workflows/ai-issue.yml
  • .github/workflows/dependabot-auto-merge.yml
  • .github/workflows/label-sync.yml
  • .github/workflows/lint.yml
  • .github/workflows/sast.yml
  • .github/workflows/scorecard.yml
  • trigger action/trigger_action.py

Comment thread .github/dependabot.yml
Comment on lines +7 to +9
labels:
- "dependencies"
- "python"

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

Missing label definitions for "python" and "actions".

The labels python (line 9) and actions (line 17) are referenced here but are not defined in .github/labels.yml. The dependencies label exists (line 55 of labels.yml), but the other two do not. This will result in Dependabot creating these labels with default styling, causing inconsistency with your managed label taxonomy.

Add these labels to .github/labels.yml:

- name: "python"
  color: "3572A5"
  description: "Python-related changes"

- name: "actions"
  color: "2088FF"
  description: "GitHub Actions workflow changes"

Also applies to: 15-17

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/dependabot.yml around lines 7 - 9, The dependabot config references
labels "python" and "actions" that are not defined in your managed label set,
causing Dependabot to create default-styled labels; add label entries for name
"python" (color 3572A5, description "Python-related changes") and name "actions"
(color 2088FF, description "GitHub Actions workflow changes") to
.github/labels.yml so they match your taxonomy and prevent auto-created
defaults.

Comment on lines +26 to +49
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'

- name: Install dependencies
run: |
pip install --no-cache-dir PyGithub==2.5.0 requests==2.32.3

- name: Run AI Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
COMMIT_SHA: ${{ github.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_MODELS_TOKEN: ${{ secrets.GH_MODELS_TOKEN }}
ALLOWED_USER: ${{ secrets.ALLOWED_USER }}
run: python "trigger action/trigger_action.py"

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 | 🔴 Critical

Do not run PR-head code with repository secrets.

This job checks out the PR branch and then executes trigger action/trigger_action.py with GH_MODELS_TOKEN plus write-scoped GITHUB_TOKEN. A same-repo PR can modify that script and exfiltrate secrets or post arbitrary issues/comments. Since the script already reads diffs via the GitHub API, it should run from a trusted ref instead of the PR head.

Suggested fix
       - name: Checkout code
         uses: actions/checkout@v6
         with:
-          fetch-depth: 0
+          ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.sha }}
+          fetch-depth: 1
📝 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
- name: Checkout code
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --no-cache-dir PyGithub==2.5.0 requests==2.32.3
- name: Run AI Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
COMMIT_SHA: ${{ github.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_MODELS_TOKEN: ${{ secrets.GH_MODELS_TOKEN }}
ALLOWED_USER: ${{ secrets.ALLOWED_USER }}
run: python "trigger action/trigger_action.py"
- name: Checkout code
uses: actions/checkout@v6
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha || github.sha }}
fetch-depth: 1
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.11'
- name: Install dependencies
run: |
pip install --no-cache-dir PyGithub==2.5.0 requests==2.32.3
- name: Run AI Analysis
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ github.repository }}
EVENT_NAME: ${{ github.event_name }}
COMMIT_SHA: ${{ github.sha }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GH_MODELS_TOKEN: ${{ secrets.GH_MODELS_TOKEN }}
ALLOWED_USER: ${{ secrets.ALLOWED_USER }}
run: python "trigger action/trigger_action.py"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ai-issue.yml around lines 26 - 49, The workflow currently
checks out and executes PR-head code (trigger_action.py) while exposing secrets
(GH_MODELS_TOKEN, GITHUB_TOKEN); change the job so it runs the analysis from a
trusted ref instead of the PR head: in the "Run AI Analysis" job (symbols:
actions/checkout@v6, trigger_action.py, GH_MODELS_TOKEN, GITHUB_TOKEN) checkout
a known safe ref (e.g., the PR base branch or a protected branch) by adding a
checkout step with ref: github.event.pull_request.base.ref (or a hardcoded
main/prod ref) before running the script, or switch the workflow to
pull_request_target and ensure checkout uses the base ref; do not pass
repository secrets to any step that runs code from the PR head.

Comment on lines +11 to +13
concurrency:
group: codeql-${{ github.ref }}-${{ matrix.language }}
cancel-in-progress: false

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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

# Locate and read the sast.yml workflow file
fd -name "sast.yml" -path "*/.github/workflows/*"

Repository: readme-SVG/readme-badges

Length of output: 298


🏁 Script executed:

# Read the file around lines 11-13 to verify the snippet
cat -n .github/workflows/sast.yml | head -25

Repository: readme-SVG/readme-badges

Length of output: 679


🌐 Web query:

GitHub Actions matrix context scope workflow-level concurrency availability

💡 Result:

Web search failed: Server error: no LLM provider could handle the message


🏁 Script executed:

# Search for GitHub Actions documentation or comments about this issue in the repo
rg -i "matrix.*context\|context.*matrix" --type yaml

Repository: readme-SVG/readme-badges

Length of output: 216


🏁 Script executed:

# Check git log for any commits related to this codeql workflow
git log --oneline .github/workflows/sast.yml | head -10

Repository: readme-SVG/readme-badges

Length of output: 161


🏁 Script executed:

# Look for any other workflows that might show correct usage patterns
fd -name "*.yml" -o -name "*.yaml" -path "*/.github/workflows/*" | xargs cat | rg -A 3 -B 3 "concurrency:" | head -40

Repository: readme-SVG/readme-badges

Length of output: 298


🏁 Script executed:

# Check if there are any issues, error logs, or discussions about workflow problems
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.log" \) | xargs grep -l -i "codeql\|workflow\|concurrency" 2>/dev/null | head -10

Repository: readme-SVG/readme-badges

Length of output: 120


🏁 Script executed:

# Look at the complete job section to understand matrix definition
sed -n '15,50p' .github/workflows/sast.yml

Repository: readme-SVG/readme-badges

Length of output: 828


🏁 Script executed:

# Search for any comments in the workflow file that might document this
cat .github/workflows/sast.yml | grep -E "^[[:space:]]*#"

Repository: readme-SVG/readme-badges

Length of output: 50


🏁 Script executed:

# Check if there's a .github directory with any run logs or artifacts
ls -la .github/

Repository: readme-SVG/readme-badges

Length of output: 561


🏁 Script executed:

# Look for any workflow run artifacts, logs, or cache
find .github -type f -name "*.log" -o -name "*.txt" 2>/dev/null

Repository: readme-SVG/readme-badges

Length of output: 50


🏁 Script executed:

# Check the complete sast.yml to confirm full structure
cat .github/workflows/sast.yml

Repository: readme-SVG/readme-badges

Length of output: 1053


🏁 Script executed:

# Check README and documentation for any mention of this workflow or issues
cat CONTRIBUTING.md README.md 2>/dev/null | grep -i -A 5 -B 5 "codeql\|workflow"

Repository: readme-SVG/readme-badges

Length of output: 661


🏁 Script executed:

# Check if there's any CI/CD status badge or documentation about workflow status
cat README.md 2>/dev/null | head -50

Repository: readme-SVG/readme-badges

Length of output: 1959


Move concurrency into the job to resolve matrix.language.

Line 12 uses ${{ matrix.language }} in the workflow-level concurrency block, but matrix context is only available at the job level. This breaks concurrency grouping and prevents proper deduplication of parallel matrix runs.

Suggested fix
 concurrency:
-  group: codeql-${{ github.ref }}-${{ matrix.language }}
+  group: codeql-${{ github.ref }}
   cancel-in-progress: false

 jobs:
   codeql:
+    concurrency:
+      group: codeql-${{ github.ref }}-${{ matrix.language }}
+      cancel-in-progress: false
     name: Analyze (${{ matrix.language }})
🧰 Tools
🪛 actionlint (1.7.12)

[error] 12-12: context "matrix" is not allowed here. available contexts are "github", "inputs", "vars". see https://docs.github.com/en/actions/learn-github-actions/contexts#context-availability for more details

(expression)


[error] 12-12: property "language" is not defined in object type {}

(expression)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/sast.yml around lines 11 - 13, Move the top-level
concurrency section into the job that defines the matrix so the matrix context
is available: remove the workflow-level "concurrency" block and add an identical
"concurrency:" block inside the job definition that uses the matrix (the job
that runs CodeQL), keeping "group: codeql-${{ matrix.language }}" and
"cancel-in-progress: false" so parallel matrix runs deduplicate correctly using
matrix.language.

Comment on lines +156 to +161
def build_permalink(filename: str, line: int = 1) -> str:
"""Build a GitHub blob permalink for a file and line number."""
sha = os.environ.get("COMMIT_SHA") or ""
if not sha and pr_ref:
sha = pr_ref.head.sha
return f"https://github.com/{repo_name}/blob/{sha}/{filename}#L{line}"

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 | 🟠 Major

Build PR permalinks from the head SHA and URL-encode the path.

On pull requests, Line 158 prefers COMMIT_SHA, and the workflow currently sets that to github.sha, which is the synthetic merge SHA rather than the PR head commit. That makes generated permalinks unstable, and paths like trigger action/trigger_action.py are emitted without URL encoding, so the link itself is malformed.

Suggested fix
+from urllib.parse import quote
+
 def build_permalink(filename: str, line: int = 1) -> str:
     """Build a GitHub blob permalink for a file and line number."""
-    sha = os.environ.get("COMMIT_SHA") or ""
-    if not sha and pr_ref:
-        sha = pr_ref.head.sha
-    return f"https://github.com/{repo_name}/blob/{sha}/{filename}#L{line}"
+    sha = pr_ref.head.sha if pr_ref else (os.environ.get("COMMIT_SHA") or "")
+    encoded_filename = quote(filename, safe="/")
+    return f"https://github.com/{repo_name}/blob/{sha}/{encoded_filename}#L{line}"
📝 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
def build_permalink(filename: str, line: int = 1) -> str:
"""Build a GitHub blob permalink for a file and line number."""
sha = os.environ.get("COMMIT_SHA") or ""
if not sha and pr_ref:
sha = pr_ref.head.sha
return f"https://github.com/{repo_name}/blob/{sha}/{filename}#L{line}"
from urllib.parse import quote
def build_permalink(filename: str, line: int = 1) -> str:
"""Build a GitHub blob permalink for a file and line number."""
sha = pr_ref.head.sha if pr_ref else (os.environ.get("COMMIT_SHA") or "")
encoded_filename = quote(filename, safe="/")
return f"https://github.com/{repo_name}/blob/{sha}/{encoded_filename}#L{line}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@trigger` action/trigger_action.py around lines 156 - 161, In build_permalink,
the code currently prefers COMMIT_SHA (which may be the synthetic merge SHA) and
doesn't URL-encode filenames; change the logic to use the PR head SHA when
pr_ref is present (use pr_ref.head.sha as the primary source, falling back to
COMMIT_SHA or empty string) and URL-encode the filename/path (e.g., via
urllib.parse.quote) before interpolating into the URL; update references in
build_permalink to use the resolved sha and the encoded filename while keeping
repo_name and line as before.

Comment on lines +442 to +456
for attempt in range(retries):
try:
resp = requests.post(ENDPOINT, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
data = resp.json()
raw = data['choices'][0]['message']['content'].strip()
raw = re.sub(r'^```json\s*|```$', '', raw, flags=re.MULTILINE).strip()
return json.loads(raw)
except Exception as e:
print(f"Attempt {attempt + 1} failed: {e}")
if attempt < retries - 1:
time.sleep(delay)

print("All attempts failed. Exiting gracefully.")
exit(0)

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 | 🟠 Major

Fail the job when analysis is actually broken.

Lines 450-456 swallow every failure path and then exit with status 0. If auth is wrong, the endpoint is down, or the model returns malformed JSON, the workflow still looks successful and the automation silently stops producing issues.

Suggested fix
-        except Exception as e:
+        except (requests.RequestException, json.JSONDecodeError, KeyError, IndexError, TypeError) as e:
             print(f"Attempt {attempt + 1} failed: {e}")
             if attempt < retries - 1:
                 time.sleep(delay)

-    print("All attempts failed. Exiting gracefully.")
-    exit(0)
+    raise SystemExit("AI analysis failed after all retries")
📝 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
for attempt in range(retries):
try:
resp = requests.post(ENDPOINT, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
data = resp.json()
raw = data['choices'][0]['message']['content'].strip()
raw = re.sub(r'^```json\s*|```$', '', raw, flags=re.MULTILINE).strip()
return json.loads(raw)
except Exception as e:
print(f"Attempt {attempt + 1} failed: {e}")
if attempt < retries - 1:
time.sleep(delay)
print("All attempts failed. Exiting gracefully.")
exit(0)
for attempt in range(retries):
try:
resp = requests.post(ENDPOINT, headers=headers, json=payload, timeout=60)
resp.raise_for_status()
data = resp.json()
raw = data['choices'][0]['message']['content'].strip()
raw = re.sub(r'^
🧰 Tools
🪛 Ruff (0.15.9)

[warning] 450-450: Do not catch blind exception: Exception

(BLE001)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@trigger` action/trigger_action.py around lines 442 - 456, The retry loop in
trigger_action.py (the for attempt in range(retries) block that posts to
ENDPOINT and calls resp.raise_for_status()/json.loads(raw)) swallows failures
and calls exit(0), making CI/workflows report success even when
requests/auth/JSON parsing fail; change the final failure behavior to surface
the error by either re-raising the last exception or calling exit with a
non-zero status (e.g., exit(1)), and include the last exception message in the
log before exiting so failures cause the job to fail rather than silently
succeeding.

@ghost
ghost merged commit 221f56d into main Apr 10, 2026
4 checks passed
This pull request was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants