Skip to content

Handle workflow events without commits - #327

Open
liurenfeng94-ops wants to merge 1 commit into
EndBug:mainfrom
liurenfeng94-ops:fix/missing-event-commits-error
Open

Handle workflow events without commits#327
liurenfeng94-ops wants to merge 1 commit into
EndBug:mainfrom
liurenfeng94-ops:fix/missing-event-commits-error

Conversation

@liurenfeng94-ops

@liurenfeng94-ops liurenfeng94-ops commented Jul 29, 2026

Copy link
Copy Markdown

Summary

Fixes #218 by replacing the current eventObj.pull_request._links.commits.href assumption with an explicit event commit resolver.

When the action runs on events that do not include commits and are not pull request events, it now fails with an actionable message that points users toward push/pull_request events or static-checking + file-url.

Validation

  • npm ci
  • npm run lint
  • npm run build
  • Smoke: workflow-dispatch-shaped event now reports the friendly error instead of throwing _links
  • Smoke: push-shaped event with commits: [] still exits successfully with changed=false

This PR was prepared with AI coding-agent assistance; I reviewed the change and ran the validation above locally.

Summary by CodeRabbit

  • Bug Fixes
    • Improved commit detection for workflow events.
    • Added clearer error messages when commit information is unavailable.
    • Prevented directory processing from starting until required commit data is resolved.

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: db501f3c-9c11-4f88-b363-e0039324ff30

📥 Commits

Reviewing files that changed from the base of the PR and between 0c56c8a and 960e6fd.

📒 Files selected for processing (2)
  • lib/index.js
  • src/main.ts

📝 Walkthrough

Walkthrough

The non-static-checking workflow now resolves commits from event data or a pull request commits link, reports a descriptive error when commits are unavailable, and processes the directory only after successful resolution.

Changes

Workflow commit resolution

Layer / File(s) Summary
Resolve and validate workflow commits
src/main.ts
getEventCommits reads commits from event data or the pull request commits link. The workflow reports supported event options when commits cannot be resolved and then calls processDirectory with the resolved list.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: handling workflow events that lack commit data.
Linked Issues check ✅ Passed The change addresses #218 by avoiding unsafe _links access and handling missing commit information with a clearer fallback.
Out of Scope Changes check ✅ Passed The changes stay focused on commit resolution and error handling in src/main.ts, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.45.0)
lib/index.js

ast-grep timed out on this file


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.

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.

Error: Cannot read properties of undefined (reading '_links')

1 participant