Repository navigation
Add PR comment, reaction and user permission commands - #16
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 93e5866. Configure here.
| func resolveCommentBody(body string, bodyFile string) string { | ||
| if bodyFile == "" { | ||
| return body | ||
| } |
There was a problem hiding this comment.
Null optional settings are not ignored
Medium Severity
When COMMENT_BODY_FILE or COMMENT_MARKER is omitted, Harness can still pass the literal string null, which this plugin already treats as unset for PR_LABELS. resolveCommentBody then tries to open a file named null and fails the step, and a null marker is treated as a real upsert key instead of always creating a comment.
suggestion
if bodyFile == "" || bodyFile == "null" {
return body
}
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 93e5866. Configure here.
There was a problem hiding this comment.
Fixed in the latest commit: a new optionalEnv helper treats null as unset for COMMENT_BODY, COMMENT_BODY_FILE and COMMENT_MARKER. Covering COMMENT_BODY too means a null body now fails with the "needs COMMENT_BODY or COMMENT_BODY_FILE" error instead of posting null as a comment.
Add three commands so a pipeline triggered by a pull request comment can talk back to the PR: - upsertPrComment: create a PR comment, or with COMMENT_MARKER update the latest comment the token owner posted with the same hidden marker. The body can come from COMMENT_BODY or COMMENT_BODY_FILE. - addReaction: add an emoji reaction to a PR/issue comment. - getUserPermission: report a user's repository permission and whether it includes write access (unknown users are reported as none). Document every command in the README, including the previously undocumented AddPullRequestLabels, waitForStatus and getRef.
f099e8c to
6325220
Compare


Summary
Adds three commands that let a pipeline started from a pull request comment respond on that pull request:
upsertPrCommentPR_NUMBER,COMMENT_BODYorCOMMENT_BODY_FILE, optionalCOMMENT_MARKERCOMMENT_ID,COMMENT_URL,COMMENT_ACTIONaddReactionCOMMENT_ID,REACTIONgetUserPermissionUSERNAMEPERMISSION,HAS_WRITE_ACCESSupsertPrComment: withoutCOMMENT_MARKER, it adds a new comment. With a marker, it appends a hidden<!-- harness-github-api-plugin:<marker> -->tag and on later runs edits the most recent comment carrying it. That keeps one up-to-date status comment per pull request. Only comments written by the token owner are matched.COMMENT_BODY_FILEtakes the body from a file in the workspace, for long or multiline content.addReaction: reacts to an issue or pull request comment, for example to acknowledge the comment that started a pipeline. The reaction is checked against the values GitHub accepts.getUserPermission: returnsadmin,write,readornone, plusHAS_WRITE_ACCESS, so a pipeline can check who is allowed to start it. A user GitHub doesn't know is reported asnoneinstead of failing the step.The README now documents every command with its outputs, including the previously undocumented
AddPullRequestLabels,waitForStatusandgetRef. It also adds an example Harness step and a note on the fixed order commands run in.Existing commands are unchanged.
Testing
gofmt -l .is clean andgo vet ./...passes with Go 1.22.5.docker build .succeeds, and the image starts as before.🤖 Generated with Claude Code