Repository navigation
[mergebot] Put GraphQL error details in the collapsed section - #201104
izaitsevfb wants to merge 3 commits into
Conversation
A GraphQL error used to put the whole query and its variables into the Reason line of the Merge failed comment. Reason now carries only GitHub's error message; the variables, raw errors and query go under Details for Dev Infra team, each size-capped to stay under GitHub's comment limit.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/201104
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 Unclassified FailureAs of commit 26149de with merge base 152bd17 ( 🟡 GREEN LIGHT - OUTDATED (earlier commit) - PR requires human review:
reason: UNCLASSIFIED FAILURE - DrCI could not classify the following job because the workflow did not run on the merge base. The failure may be pre-existing on trunk or introduced by this PR:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
|
@claude Review this change |
|
Claude finished @huydhn's task in 1m 3s —— View job The comment change looks right, but I'd request changes for two things: the lint-urls failure caused by a test URL, and the query/variables no longer showing up in job logs for any script that raises a GraphQL error. PR Review: #201104SummaryThe PR shortens the GraphQL error message, moves the query, variables and raw errors into the collapsed "Details for Dev Infra team" section, and pulls Code Quality
Testing
Backward Compatibility
RecommendationRequest Changes: the test URL breaks a CI lint job, and the query/variables context should stay in tracebacks and logs (for example via |
|
Plz fix lint. Also, the agent review makes sense to me as I usually looks into the merge job to debug issue instead of its comment.
|
gh_graphql now prints the query, variables and errors to the job log when it raises, and GHGraphQLError adds them as an exception note on Python 3.11+. Mergebot runs on 3.10, where tracebacks don't show notes. An empty errors list now reads '(no error message)'. The test's fake run URL carries @lint-ignore so lint-urls skips it.
|
@pytorchbot merge -i |
Merge startedYour change will be merged while ignoring the following 1 checks: pull / linux-jammy-aarch64-py3.11-clang21 / build Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
…erdicts to the run they analyzed (#9139) ✴️ iz2: ## Problem When a failed PR job is re-run at the same commit (pytorch-bot's auto-retry, or by hand), AI advisor suppression can never clear it. There are two causes: - Auto-dispatch dedups on `(head sha, job name)`, so the rerun is never analyzed. - The suppression gate ignores a verdict written before the job finished, so the first run's verdict never applies to the rerun. Together these keep the job blocking for good, and the PR needs `merge -i`. Example: pytorch/pytorch#201104. Its `linux-jammy-aarch64-py3.11-clang21 / build` job got `not_related` @ 0.95 at 00:54:54Z, then attempt 2 finished at 01:13:57Z. In the last 7 days, 62 of 1,790 analyzed jobs had a later run that finished after the dispatch and failed again. The comment line and the badge also kept showing the first run's "not related" for the rerun, which contradicts the gate. The badge image is keyed only by sha + job and cached for a day. ## Change - **Re-dispatch reruns.** A job whose run finished at or after the latest live dispatch is dispatched again, reusing its budget slot. This waits until the previous analysis has answered (a verdict newer than that dispatch), so normally one analysis per key is in flight. drci.ts now reads verdict rows before auto-dispatch for this, also when the comment and suppression flags are off. - **Bind a verdict to a run through its dispatch** (`verdictCoversRun`). A verdict counts for a run only if the latest live dispatch was made after the run finished and the verdict is newer than that dispatch. The gate, the comment line and the badge all use this test. Before, the gate only required the verdict to be newer than the job's completion. That let an analysis of an earlier run that was still running when the rerun finished clear the rerun, which is the "KNOWN GAP" in `advisorSuppression.ts`. completed_at has whole-second precision, so a dispatch only counts from the next second. - **Dispatch row versions mark when evidence was captured.** Terminal rows (`dispatched` / `failed`) are stamped 1ms after the pre-dispatch row, which is written before the signal pattern is built, instead of at confirmation time. The manual endpoint allocates its pre-dispatch version before writing, so a write that persists but throws still sorts below the terminal row. - **Comment and badge.** A verdict that does not cover the run is not shown. A live, unanswered, owed or retryable dispatch renders the in-progress line, whose pending sentinel keeps the PR in the sweep. So does a verdict whose key has no dispatch row while auto-dispatch is on, since auto-dispatch will dispatch it. Any other verdict renders a new "outdated" line. The badge URL carries `since=<completed_at>`, so each run gets its own camo-cached image. URLs without it behave as before. - drci.ts reads dispatch states once, after auto-dispatch, and shares them between the line and the gate. If that read fails, the gate blocks and the lines keep the sentinel. Production check: all 1,838 `dr_ci_` verdicts from the last 7 days have a live dispatch row older than the verdict, so the new gate does not newly block existing first-run verdicts. ## Known limitations - Verdict rows do not record which dispatch they answer. An earlier analysis can still be counted for a later dispatch in two cases: two renders dispatch the same key at the same moment, or GitHub accepts a dispatch whose POST still throws, so it is recorded `failed` and retried. Neither case is wider than main's current gap. Closing them needs the advisor to write a dispatch id on the verdict row. - ClickHouse ingest window: a rerun that finishes just before the first dispatch but is not yet in `workflow_job` can still be cleared by an earlier run's verdict. In a 2026-10-09 case, the job finished 12s before the dispatch row and was inserted 46s after it. A follow-up PR will record the analyzed job id on the dispatch row. - The manual "AI Analyze" button still returns 409 for a key whose latest row is live. ## Query performance Both changed queries only add a column. WHERE clauses are unchanged. | query | granules kept/total | elapsed before → after | |---|---|---| | `advisor_dispatch_states` (+ `max(version) AS latest_version`) | 2/6 | 0.55s → 0.71s (single run each, network-dominated) | | `advisor_verdict_for_job` (+ `timestamp`) | 3/15 | 0.60s → 0.73s (single run each, network-dominated) | ## Testing `next lint`, `tsc` and `jest` pass locally. New tests cover rerun re-dispatch and its serialization, dispatch-bound coverage in the gate, line and badge selection (including a verdict with no dispatch row), whole-second ordering, version stamping, and the verdict read with only auto-dispatch on.
…h#201104) ✴️ iz2: When a GitHub GraphQL call fails, mergebot's "Merge failed" comment put the whole query and its variables on the **Reason** line, about 40 lines of query text (example: pytorch#200980). Now **Reason** shows only GitHub's error message, on one line (or "(no error message)" when the errors list is empty): > **Reason**: GitHub GraphQL query failed: Something went wrong while executing your query on 2026-10-15T17:52:34Z. Please include `83C2:…` when reporting this issue. The variables, raw errors and query move into "Details for Dev Infra team" as fenced blocks, each size-capped to keep the comment under GitHub's 65536-char limit. The same context also stays in the job log for every `gh_graphql` caller: `gh_graphql` prints it when it raises, and `GHGraphQLError` adds it as an exception note on Python 3.11+ (mergebot runs on 3.10, where tracebacks don't show notes). `handle_exception` becomes the module-level `format_failure_comment()` so it can be tested. The details block now also appears when there is a failing merge rule but `GH_RUN_URL` is unset. **Exposure check:** the comment and log contain nothing sensitive. The token is sent as an HTTP header and never reaches the exception. The query text is already in this repo. The variables are owner, repo name, PR number and opaque pagination cursors. The request ID is the one GitHub asks you to share. Test plan: `python -m unittest test_trymerge test_delete_old_branches` in `.github/scripts` (Python 3.12): 159 pass, 2 skipped. `TestFailureComment` covers the short reason, empty errors, the log output and note, the collapsed details, size caps, the merge-rule case and the no-details case. Pull Request resolved: pytorch#201104 Approved by: https://github.com/huydhn
✴️ iz2: When a GitHub GraphQL call fails, mergebot's "Merge failed" comment put the whole query and its variables on the Reason line, about 40 lines of query text (example: #200980).
Now Reason shows only GitHub's error message, on one line (or "(no error message)" when the errors list is empty):
The variables, raw errors and query move into "Details for Dev Infra team" as fenced blocks, each size-capped to keep the comment under GitHub's 65536-char limit. The same context also stays in the job log for every
gh_graphqlcaller:gh_graphqlprints it when it raises, andGHGraphQLErroradds it as an exception note on Python 3.11+ (mergebot runs on 3.10, where tracebacks don't show notes).handle_exceptionbecomes the module-levelformat_failure_comment()so it can be tested. The details block now also appears when there is a failing merge rule butGH_RUN_URLis unset.Exposure check: the comment and log contain nothing sensitive. The token is sent as an HTTP header and never reaches the exception. The query text is already in this repo. The variables are owner, repo name, PR number and opaque pagination cursors. The request ID is the one GitHub asks you to share.
Test plan:
python -m unittest test_trymerge test_delete_old_branchesin.github/scripts(Python 3.12): 159 pass, 2 skipped.TestFailureCommentcovers the short reason, empty errors, the log output and note, the collapsed details, size caps, the merge-rule case and the no-details case.