@sentry/junior-github 0.91.0 → 0.92.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/SETUP.md CHANGED
@@ -98,9 +98,9 @@ Use `additionalUserScopes` only when an integration flow requires specific GitHu
98
98
  ## 3) Runtime behavior
99
99
 
100
100
  - When either GitHub skill is active, authenticated `gh` and `git` commands cause the runtime to inject GitHub credentials automatically for the current turn.
101
- - The plugin classifies GitHub traffic from the forwarded HTTP request. Safe app-readable API methods, GraphQL `GET`/`HEAD`/`OPTIONS` requests, GraphQL `POST` bodies that prove the operation is a query, and `git-upload-pack` use the `installation-read` grant. `GET /user` uses the `user-read` grant so account identity checks use the requester token. Write-specific REST URLs, GraphQL mutations/subscriptions, unknown GraphQL `POST` bodies, other non-read API methods, and `git-receive-pack` use the `user-write` grant.
102
- - `user-read` and `user-write` require the requester, or an explicitly delegated user subject from an allowed system run, to authorize the GitHub App through the private OAuth flow. Missing or expired user authorization pauses interactive turns, sends a private authorization link, and resumes after approval.
103
- - Git commits use the requester as the commit author, Junior as committer, and a Junior `Co-Authored-By` trailer.
101
+ - The plugin classifies GitHub traffic from the forwarded HTTP request. Safe app-readable API methods, GraphQL `GET`/`HEAD`/`OPTIONS` requests, GraphQL `POST` bodies that prove the operation is a query, and `git-upload-pack` use the `installation-read` grant. `GET /user` uses the `user-read` grant so account identity checks use the actor token. Write-specific REST URLs, GraphQL mutations/subscriptions, unknown GraphQL `POST` bodies, other non-read API methods, and `git-receive-pack` use the `user-write` grant.
102
+ - `user-read` and `user-write` require the actor, or an explicitly delegated user subject from an allowed system run, to authorize the GitHub App through the private OAuth flow. Missing or expired user authorization pauses interactive turns, sends a private authorization link, and resumes after approval.
103
+ - Git commits use the actor as the commit author, Junior as committer, and a Junior `Co-Authored-By` trailer.
104
104
  - Issued credentials are reused only within the current turn, credential leases are cached separately by plugin grant name, and upstream 403 permission denials clear the cached lease before the next retry.
105
105
  - Sandbox does not receive raw tokens via env; host applies Authorization header transforms for GitHub API calls.
106
106
 
@@ -132,7 +132,7 @@ The plugin uses `installation-read` for read-only GitHub traffic and `user-write
132
132
 
133
133
  Committing and pushing code uses more than one GitHub surface:
134
134
 
135
- - Creating the local Git commit does not call GitHub. Junior sets the requester as author and the GitHub App bot as committer in the sandbox.
135
+ - Creating the local Git commit does not call GitHub. Junior sets the actor as author and the GitHub App bot as committer in the sandbox.
136
136
  - Pushing a branch with Git smart HTTP (`git push`) uses the `user-write` grant and requires the GitHub App to have `Contents: write` on the target repository. The requesting user must also have write access to that repository.
137
137
  - REST Git database writes used by some `gh` flows also require `Contents: write`: create blob (`POST /git/blobs`), create tree (`POST /git/trees`), create commit (`POST /git/commits`), and create/update refs (`POST /git/refs`, `PATCH /git/refs/{ref}`). Changes to workflow files may also require `Workflows: write`.
138
138
  - Opening the PR after the branch exists is separate: `github_createPullRequest` needs pull-request write permission, but it should not create or push commits itself.
package/dist/index.js CHANGED
@@ -887,18 +887,27 @@ function cleanIdentityPart(value) {
887
887
  function isSlackUserId(value) {
888
888
  return /^[UW][A-Z0-9]{5,}$/.test(value);
889
889
  }
890
- function requesterDisplayName(value, requester) {
890
+ function isUserActor(actor) {
891
+ return Boolean(actor && "userId" in actor);
892
+ }
893
+ function actorDisplayName(value, actor) {
891
894
  const name = cleanIdentityPart(value);
892
- if (!name || name.toLowerCase() === "unknown" || name === cleanIdentityPart(requester?.userId)) {
895
+ if (!name || name.toLowerCase() === "unknown" || name === cleanIdentityPart(isUserActor(actor) ? actor.userId : void 0)) {
893
896
  return void 0;
894
897
  }
895
898
  return isSlackUserId(name) ? void 0 : name;
896
899
  }
897
- function requesterName(requester) {
898
- return requesterDisplayName(requester?.fullName, requester) || requesterDisplayName(requester?.userName, requester) || void 0;
900
+ function actorName(actor) {
901
+ if (!isUserActor(actor)) {
902
+ return void 0;
903
+ }
904
+ return actorDisplayName(actor?.fullName, actor) || actorDisplayName(actor?.userName, actor) || void 0;
899
905
  }
900
- function requesterEmail(requester) {
901
- const email = cleanIdentityPart(requester?.email);
906
+ function actorEmail(actor) {
907
+ if (!isUserActor(actor)) {
908
+ return void 0;
909
+ }
910
+ const email = cleanIdentityPart(actor?.email);
902
911
  return /^[^\s@<>]+@[^\s@<>]+\.[^\s@<>]+$/.test(email) ? email : void 0;
903
912
  }
904
913
  function isGitCommitCommand(command) {
@@ -916,12 +925,12 @@ if [ -z "$message_file" ]; then
916
925
  fi
917
926
 
918
927
  if [ -z "\${JUNIOR_GIT_AUTHOR_NAME:-}" ] || [ -z "\${JUNIOR_GIT_AUTHOR_EMAIL:-}" ]; then
919
- echo "Junior GitHub plugin internal error: requester commit attribution was not injected by the host runtime. Do not set Git author env vars manually; report this configuration error." >&2
928
+ echo "Junior GitHub plugin internal error: actor commit attribution was not injected by the host runtime. Do not set Git author env vars manually; report this configuration error." >&2
920
929
  exit 1
921
930
  fi
922
931
 
923
932
  if [ "\${GIT_AUTHOR_NAME:-}" != "$JUNIOR_GIT_AUTHOR_NAME" ] || [ "\${GIT_AUTHOR_EMAIL:-}" != "$JUNIOR_GIT_AUTHOR_EMAIL" ]; then
924
- echo "Junior GitHub plugin internal error: Git author was not set to the resolved requester identity. Do not override Git author manually; report this configuration error." >&2
933
+ echo "Junior GitHub plugin internal error: Git author was not set to the resolved actor identity. Do not override Git author manually; report this configuration error." >&2
925
934
  exit 1
926
935
  fi
927
936
 
@@ -1828,11 +1837,11 @@ function githubPlugin(options = {}) {
1828
1837
  if (!botName || !botEmail) {
1829
1838
  return;
1830
1839
  }
1831
- const authorName = requesterName(ctx.requester);
1832
- const authorEmail = requesterEmail(ctx.requester);
1840
+ const authorName = actorName(ctx.actor);
1841
+ const authorEmail = actorEmail(ctx.actor);
1833
1842
  if ((!authorName || !authorEmail) && isGitCommitCommand(command)) {
1834
1843
  ctx.decision.deny(
1835
- "Junior GitHub plugin could not determine a resolved requester name and email for commit attribution. This is an internal request-context error; do not set author env vars manually."
1844
+ "Junior GitHub plugin could not determine a resolved actor name and email for commit attribution. This is an internal request-context error; do not set author env vars manually."
1836
1845
  );
1837
1846
  return;
1838
1847
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sentry/junior-github",
3
- "version": "0.91.0",
3
+ "version": "0.92.0",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -25,7 +25,7 @@
25
25
  "dependencies": {
26
26
  "@sinclair/typebox": "^0.34.49",
27
27
  "zod": "^4.4.3",
28
- "@sentry/junior-plugin-api": "0.91.0"
28
+ "@sentry/junior-plugin-api": "0.92.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@types/node": "^25.9.1",
@@ -62,7 +62,7 @@ jr-rpc config set github.repo owner/repo
62
62
 
63
63
  - Prefer `--json` output for machine-readable parsing where available.
64
64
  - Pass extra `git clone` flags after `--` (e.g. `gh repo clone owner/repo -- --depth=1`).
65
- - A local `git commit` does not call GitHub. Pushing that commit does: `git push` requires `github.contents.write` on the target repo and requester write access.
65
+ - A local `git commit` does not call GitHub. Pushing that commit does: `git push` requires `github.contents.write` on the target repo and actor write access.
66
66
  - REST Git commit construction also requires `github.contents.write`: `POST /git/blobs`, `POST /git/trees`, `POST /git/commits`, `POST /git/refs`, and `PATCH /git/refs/{ref}`.
67
67
  - If the commit changes workflow files under `.github/workflows`, expect `github.workflows.write` in addition to contents write.
68
68
  - Before `github_createPullRequest`, push the head branch explicitly and resolve the target repo's default branch for `base`. That push requires GitHub write access to the remote.