@sentry/junior-github 0.262.0 → 0.263.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/dist/clone-command.d.ts +2 -2
- package/dist/egress-policy.d.ts +8 -2
- package/dist/index.js +56 -15
- package/package.json +2 -2
- package/skills/github-code/SPEC.md +1 -0
- package/skills/github-code/references/api-surface.md +1 -0
- package/skills/github-code/references/troubleshooting-workarounds.md +2 -2
- package/skills/github-code/references/workflow.md +5 -0
- package/skills/github-issues/references/troubleshooting-workarounds.md +13 -13
package/dist/clone-command.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Return a
|
|
2
|
+
* Return a redirect message when a bash command clones a GitHub repository
|
|
3
3
|
* without `github_cloneRepository`. Return undefined for other commands.
|
|
4
4
|
*/
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function githubCloneCommandRedirect(command: string): string | undefined;
|
package/dist/egress-policy.d.ts
CHANGED
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import { type EgressHookContext, type EgressResponseHookContext } from "@sentry/junior-plugin-api";
|
|
8
8
|
import { type GitHubGrant } from "./credential-support.js";
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Classify a GitHub response as a permission denial.
|
|
11
|
+
*
|
|
12
|
+
* Returns a message only when GitHub says that the credential lacks access.
|
|
13
|
+
* Other GitHub refusals return undefined, so the runtime does not call them
|
|
14
|
+
* permission problems.
|
|
15
|
+
*/
|
|
16
|
+
export declare function githubPermissionDeniedMessage(ctx: EgressResponseHookContext): Promise<string | undefined>;
|
|
11
17
|
export declare function githubGrantForEgress(ctx: EgressHookContext): Promise<GitHubGrant>;
|
package/dist/index.js
CHANGED
|
@@ -4708,10 +4708,10 @@ async function prepareWorkspace(ctx) {
|
|
|
4708
4708
|
|
|
4709
4709
|
// src/clone-command.ts
|
|
4710
4710
|
import { parseShellCommands } from "@sentry/junior-plugin-api";
|
|
4711
|
-
var
|
|
4711
|
+
var CLONE_REDIRECT_MESSAGE = "Use github_cloneRepository to clone GitHub repositories, not git clone or gh repo clone. It checks for a matching Workspace first.";
|
|
4712
4712
|
var GIT_OPTIONS_WITH_VALUE = /* @__PURE__ */ new Set(["-C", "-c"]);
|
|
4713
|
-
function
|
|
4714
|
-
return parseShellCommands(command).some(isGitHubClone) ?
|
|
4713
|
+
function githubCloneCommandRedirect(command) {
|
|
4714
|
+
return parseShellCommands(command).some(isGitHubClone) ? CLONE_REDIRECT_MESSAGE : void 0;
|
|
4715
4715
|
}
|
|
4716
4716
|
function isGitHubClone([program, ...args]) {
|
|
4717
4717
|
if (program === "gh") {
|
|
@@ -4950,6 +4950,50 @@ function shouldInspectGitHubGraphqlResponse(ctx) {
|
|
|
4950
4950
|
const contentType = ctx.response.headers.get("content-type");
|
|
4951
4951
|
return contentType ? /\bjson\b/i.test(contentType) : false;
|
|
4952
4952
|
}
|
|
4953
|
+
var GITHUB_ERROR_BODY_LIMIT_BYTES = 4 * 1024;
|
|
4954
|
+
var GITHUB_ACCESS_DENIED_MESSAGE = "Resource not accessible by integration";
|
|
4955
|
+
var GITHUB_ACCEPTED_PERMISSIONS_PATTERN = /^[a-z_]+=[a-z]+(?:\s*[,;]\s*[a-z_]+=[a-z]+)*$/;
|
|
4956
|
+
function githubErrorMessage(bodyText) {
|
|
4957
|
+
if (!bodyText) {
|
|
4958
|
+
return void 0;
|
|
4959
|
+
}
|
|
4960
|
+
try {
|
|
4961
|
+
const parsed = JSON.parse(bodyText);
|
|
4962
|
+
return isRecord(parsed) && typeof parsed.message === "string" ? parsed.message.trim() : void 0;
|
|
4963
|
+
} catch {
|
|
4964
|
+
return void 0;
|
|
4965
|
+
}
|
|
4966
|
+
}
|
|
4967
|
+
async function githubForbiddenPermissionDeniedMessage(ctx) {
|
|
4968
|
+
const sso = ctx.response.headers.get("x-github-sso");
|
|
4969
|
+
if (sso?.startsWith("required")) {
|
|
4970
|
+
const url = sso.match(/\burl=(https:\/\/github\.com\/\S+)/)?.[1];
|
|
4971
|
+
return `GitHub requires SAML SSO authorization for this credential.${url ? ` Authorize it at ${url}` : ""}`;
|
|
4972
|
+
}
|
|
4973
|
+
const message = githubErrorMessage(
|
|
4974
|
+
await ctx.response.readText(GITHUB_ERROR_BODY_LIMIT_BYTES)
|
|
4975
|
+
);
|
|
4976
|
+
if (message !== GITHUB_ACCESS_DENIED_MESSAGE) {
|
|
4977
|
+
return void 0;
|
|
4978
|
+
}
|
|
4979
|
+
const accepted = ctx.response.headers.get("x-accepted-github-permissions")?.trim();
|
|
4980
|
+
return [
|
|
4981
|
+
`GitHub denied access: ${message}.`,
|
|
4982
|
+
...accepted && GITHUB_ACCEPTED_PERMISSIONS_PATTERN.test(accepted) ? [`This endpoint accepts these GitHub permissions: ${accepted}.`] : []
|
|
4983
|
+
].join(" ");
|
|
4984
|
+
}
|
|
4985
|
+
async function githubPermissionDeniedMessage(ctx) {
|
|
4986
|
+
if (ctx.response.status === 403) {
|
|
4987
|
+
return await githubForbiddenPermissionDeniedMessage(ctx);
|
|
4988
|
+
}
|
|
4989
|
+
if (!shouldInspectGitHubGraphqlResponse(ctx)) {
|
|
4990
|
+
return void 0;
|
|
4991
|
+
}
|
|
4992
|
+
const bodyText = await ctx.response.readText(
|
|
4993
|
+
GITHUB_GRAPHQL_RESPONSE_BODY_LIMIT_BYTES
|
|
4994
|
+
);
|
|
4995
|
+
return bodyText ? githubGraphqlPermissionDeniedMessage(bodyText) : void 0;
|
|
4996
|
+
}
|
|
4953
4997
|
var PULL_REQUEST_COMMENT_REACTIONS_PATH = /^\/repos\/[^/]+\/[^/]+\/(issues|pulls)\/comments\/[^/]+\/reactions(?:\/[^/]+)?$/;
|
|
4954
4998
|
var GITHUB_BODY_WRITES = [
|
|
4955
4999
|
{
|
|
@@ -5467,9 +5511,9 @@ function githubPlugin(options = {}) {
|
|
|
5467
5511
|
if (ctx.tool.name !== "bash") {
|
|
5468
5512
|
return;
|
|
5469
5513
|
}
|
|
5470
|
-
const
|
|
5471
|
-
if (
|
|
5472
|
-
ctx.decision.
|
|
5514
|
+
const cloneRedirect = typeof ctx.tool.input.command === "string" ? githubCloneCommandRedirect(ctx.tool.input.command) : void 0;
|
|
5515
|
+
if (cloneRedirect) {
|
|
5516
|
+
ctx.decision.redirect(cloneRedirect);
|
|
5473
5517
|
return;
|
|
5474
5518
|
}
|
|
5475
5519
|
const botName = requireEnv(botNameEnv);
|
|
@@ -5502,16 +5546,13 @@ function githubPlugin(options = {}) {
|
|
|
5502
5546
|
return githubGrantForEgress(ctx);
|
|
5503
5547
|
},
|
|
5504
5548
|
async onEgressResponse(ctx) {
|
|
5505
|
-
if (
|
|
5506
|
-
|
|
5507
|
-
|
|
5508
|
-
|
|
5509
|
-
|
|
5510
|
-
);
|
|
5511
|
-
if (!bodyText) {
|
|
5512
|
-
return;
|
|
5549
|
+
if (ctx.response.status === 403) {
|
|
5550
|
+
ctx.log.warn("github.egress.upstream_forbidden", {
|
|
5551
|
+
"app.github.accepted_permissions": ctx.response.headers.get("x-accepted-github-permissions") ?? void 0,
|
|
5552
|
+
"app.github.sso": ctx.response.headers.get("x-github-sso") ?? void 0
|
|
5553
|
+
});
|
|
5513
5554
|
}
|
|
5514
|
-
const message =
|
|
5555
|
+
const message = await githubPermissionDeniedMessage(ctx);
|
|
5515
5556
|
if (message) {
|
|
5516
5557
|
ctx.permissionDenied(message);
|
|
5517
5558
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sentry/junior-github",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.263.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"drizzle-orm": "^0.45.2",
|
|
33
33
|
"marked": "^18.1.2",
|
|
34
34
|
"zod": "^4.5.4",
|
|
35
|
-
"@sentry/junior-plugin-api": "0.
|
|
35
|
+
"@sentry/junior-plugin-api": "0.263.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@oxlint/plugins": "1.79.0",
|
|
@@ -11,6 +11,7 @@ Guide evidence-first GitHub repository work from inspection through a reviewable
|
|
|
11
11
|
- Treat shallow clones as inspection checkouts; deepen before history work; never force-push around missing ancestry.
|
|
12
12
|
- Install dependencies with the lockfile frozen mode before verification when needed.
|
|
13
13
|
- Finish completed edits with a pushed PR unless the user opts out; default draft.
|
|
14
|
+
- After each push to a branch with an open PR, check mergeability. Resolve conflicts without asking, by merging the PR base branch (usually the default branch). Never rebase for this. GitHub sends no event for a new conflict, and conflicted PRs get no new checks.
|
|
14
15
|
- Write conventional PR titles and short plain-English bodies; keep check results out of the PR body.
|
|
15
16
|
- Report exact validation and permission failures.
|
|
16
17
|
|
|
@@ -45,6 +45,7 @@ If the user omits `owner/repo`, run `jr-rpc config get github.repo`. Then pass `
|
|
|
45
45
|
| Resolve review thread | `github_resolvePullRequestReviewThread` |
|
|
46
46
|
| Inline review comment | `gh api repos/owner/repo/pulls/NUMBER/comments --method POST --input comment.json` |
|
|
47
47
|
| View PR / checks | `gh pr view NUMBER --repo owner/repo` / `gh pr checks NUMBER --repo owner/repo` |
|
|
48
|
+
| PR mergeability | `gh pr view NUMBER --repo owner/repo --json mergeable,baseRefName` |
|
|
48
49
|
| Diff PR | `gh pr diff NUMBER --repo owner/repo` |
|
|
49
50
|
| List runs | `gh run list -R owner/repo --workflow WORKFLOW` |
|
|
50
51
|
| View / watch run | `gh run view RUN_ID -R owner/repo` / `gh run watch RUN_ID -R owner/repo --exit-status` |
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
| GraphQL cannot find the repository | Check `owner/repo` and the GitHub App installation. |
|
|
8
8
|
| `junior-auth-required` with `user-write` | Follow the private OAuth prompt. Never ask for a pasted token. |
|
|
9
9
|
| `git push` returns 401 or 403 | Check the remote and repository. Retry once, then report the installation access failure. |
|
|
10
|
-
| `permission_denied` has `source: "upstream"` | GitHub
|
|
10
|
+
| `permission_denied` has `source: "upstream"` | Read GitHub's error. Report an access problem only if it says access denied or SSO. |
|
|
11
11
|
| Other 403 response | Read the error and use the tool it names. |
|
|
12
12
|
| `gh auth status` shows no token scopes | This is normal for GitHub App user tokens. Check App permissions instead. |
|
|
13
13
|
| `github_createPullRequest` returns 401 or 403 | Report the installation access failure. Do not use user OAuth. |
|
|
@@ -27,5 +27,5 @@
|
|
|
27
27
|
- Retry a transport failure once after you check the repository.
|
|
28
28
|
- Do not repeat 401, 403, 404, or validation failures.
|
|
29
29
|
- A `user-read` or `user-write` failure needs private App OAuth.
|
|
30
|
-
- An `installation-*`
|
|
30
|
+
- An `installation-*` access denial needs an App permission or installation fix.
|
|
31
31
|
- Use structured `permission_denied` details when present.
|
|
@@ -34,6 +34,11 @@ Open this when making repository edits, not for read-only inspection.
|
|
|
34
34
|
1. Reuse the current non-default branch or create a focused branch.
|
|
35
35
|
2. Commit with repo conventions, else `<type>(<scope>): <Subject>` imperative present, no agent branding.
|
|
36
36
|
3. Push with `git push -u origin BRANCH`.
|
|
37
|
+
If the branch has an open PR, check that it can merge. Do this after every push, including fixes for review feedback or failed checks. A conflicted PR gets no new checks, so no event shows it.
|
|
38
|
+
- Run `gh pr view NUMBER --repo owner/repo --json mergeable,baseRefName`.
|
|
39
|
+
- `UNKNOWN`: GitHub is still calculating it. Wait about 5 seconds and check again, up to 3 times. If it stays `UNKNOWN`, report that and continue.
|
|
40
|
+
- `CONFLICTING`: resolve it now. Do not ask first. GitHub checks mergeability against the PR base (`baseRefName`), which is usually the default branch. Fetch the base and merge `origin/BASE` into the PR branch. Do not rebase. Resolve each conflict so that both the PR change and the base branch change stay intact. Run the checks again, push, and check mergeability again.
|
|
41
|
+
- In the report, name the files that had conflicts and say how you resolved them.
|
|
37
42
|
4. Resolve the actual default branch.
|
|
38
43
|
5. Update an existing PR for the branch with `github_updatePullRequest`, or create with `github_createPullRequest` (`draft: true` only when work, checks, or decisions remain; otherwise ready for review).
|
|
39
44
|
6. PR title matches the current dominant change, same conventional form as commits.
|
|
@@ -2,19 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
Use this table to recover quickly while keeping operations deterministic.
|
|
4
4
|
|
|
5
|
-
| Symptom | Likely cause
|
|
6
|
-
| ---------------------------------------------------------- |
|
|
7
|
-
| `unknown command "issue"` from `gh` | CLI version too old or wrong binary in the plugin runtime.
|
|
8
|
-
| `Missing required option --repo` | Repo not passed and no default was resolved.
|
|
9
|
-
| Command affects or authenticates against the wrong repo | Stale `github.repo` default or authenticated command missing explicit repo.
|
|
10
|
-
| `GraphQL: Could not resolve to a Repository` | Repo slug is wrong or inaccessible.
|
|
11
|
-
| 401 Unauthorized | Issued GitHub credentials were rejected upstream.
|
|
12
|
-
| `junior-auth-required provider=github grant=user-write` | User-to-server OAuth is missing or stale for a human-identity operation.
|
|
13
|
-
| 403 without `permission_denied` where `source: "upstream"` | The runtime may have rejected an unsupported route before contacting GitHub. | Read the response body. Follow any required-tool instruction; do not ask for GitHub permissions unless the failure is confirmed upstream.
|
|
14
|
-
| `permission_denied` with `source: "upstream"` | GitHub rejected the
|
|
15
|
-
| 404 Not Found | Issue number or repo is wrong.
|
|
16
|
-
| Issue label mutation fails | Wrong REST payload or wrong repo context.
|
|
17
|
-
| Comment command fails with empty body | JSON input is missing a non-empty `body`.
|
|
5
|
+
| Symptom | Likely cause | Fix |
|
|
6
|
+
| ---------------------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
7
|
+
| `unknown command "issue"` from `gh` | CLI version too old or wrong binary in the plugin runtime. | Verify `gh --version`; if it is unavailable or too old, report that the GitHub plugin runtime dependency is not available. |
|
|
8
|
+
| `Missing required option --repo` | Repo not passed and no default was resolved. | Resolve with `jr-rpc config get github.repo`; pass `--repo owner/repo` explicitly when missing. |
|
|
9
|
+
| Command affects or authenticates against the wrong repo | Stale `github.repo` default or authenticated command missing explicit repo. | Pass `--repo owner/repo` for the target repository, or update `github.repo` before retrying. |
|
|
10
|
+
| `GraphQL: Could not resolve to a Repository` | Repo slug is wrong or inaccessible. | Validate `owner/repo` and confirm app installation on target repository. |
|
|
11
|
+
| 401 Unauthorized | Issued GitHub credentials were rejected upstream. | Verify the target repo, then use the grant/auth signal to distinguish stale user OAuth from app installation or host env setup. |
|
|
12
|
+
| `junior-auth-required provider=github grant=user-write` | User-to-server OAuth is missing or stale for a human-identity operation. | Follow the private OAuth prompt; do not ask the user to paste or manage tokens manually. |
|
|
13
|
+
| 403 without `permission_denied` where `source: "upstream"` | The runtime may have rejected an unsupported route before contacting GitHub. | Read the response body. Follow any required-tool instruction; do not ask for GitHub permissions unless the failure is confirmed upstream. |
|
|
14
|
+
| `permission_denied` with `source: "upstream"` | GitHub rejected the forwarded request. | Read GitHub's error first. If the message says GitHub denied access, verify the target, App permissions, and installation scope. Do not request user OAuth for a bot-owned issue operation. |
|
|
15
|
+
| 404 Not Found | Issue number or repo is wrong. | Validate repo + issue ID with `gh issue view NUMBER --repo owner/repo`. |
|
|
16
|
+
| Issue label mutation fails | Wrong REST payload or wrong repo context. | Use the allowlisted issue labels endpoint with an explicit `owner/repo` path and valid JSON input. |
|
|
17
|
+
| Comment command fails with empty body | JSON input is missing a non-empty `body`. | Ensure the REST comment payload contains a non-empty `body` before retrying. |
|
|
18
18
|
|
|
19
19
|
## Retry guidance
|
|
20
20
|
|