fix(settings): handle nop mode results when check run is missing#1018
Open
tdabasinskas wants to merge 4 commits into
Open
fix(settings): handle nop mode results when check run is missing#1018tdabasinskas wants to merge 4 commits into
tdabasinskas wants to merge 4 commits into
Conversation
In nop mode, when triggered outside the webhook flow (e.g., via the full-sync entrypoint), the payload lacks a check run or repository. Previously, this would cause errors when attempting to update a non-existent check run. Now logs dry-run results to the console instead of attempting to update a check run when `payload.check_run` is undefined. This allows full-sync operations to complete successfully in nop mode while still providing visibility into the results.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a dry-run (nop) crash in handleResults when running outside the webhook flow (e.g., full sync/CLI/scheduled runs) by avoiding access to missing check_run payload fields and instead logging the dry-run plan.
Changes:
- Add a
nop-mode guard inhandleResultsto log results and skip check-run/PR-comment reporting whenpayload.check_runis missing. - Add unit tests covering
handleResultsbehavior for both “no check_run” (full sync) and “has check_run” (webhook)nopcontexts.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| lib/settings.js | Adds an early-return guard in handleResults for nop runs without payload.check_run, logging dry-run results instead of calling Checks/Issues APIs. |
| test/unit/lib/settings.test.js | Adds unit coverage ensuring nop full-sync contexts log results and webhook contexts still complete the check run. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
The nop mode check was only verifying the presence of `check_run` in the payload, but the full-sync entrypoint can have a check run without a repository object. This caused the code to attempt posting results when it should have logged them instead. Add an additional check for `payload.repository` to ensure both fields are present before attempting to update the check run.
When running in nop mode without a check run (e.g. full-sync), the results previously went to info level logs. Since the full diff can contain sensitive configuration values like Actions variables, this now: - Logs the full diff at debug level only - Logs a summary at info level that excludes config values - Shows the count of planned changes and references the debug log
Change the debug log call to pass results as an object instead of a serialized string. This ensures the logger only serializes the results when debug level is actually emitted, preventing unnecessary exposure of sensitive config values in logs. The previous implementation always serialized results to JSON before passing to the logger, which could expose sensitive values even when debug logging was disabled.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #818.
syncInstallationbuilds a minimal context whose payload only containsinstallation, but the nop branch ofhandleResultsunconditionally readspayload.check_run.idandpayload.repository.owner.login(andpayload.check_run.check_suite.pull_requestswhenCREATE_PR_COMMENTis on). Those fields only exist in the webhook flow. This is the root cause @ctbui and @jamengual identified in the issue comments.This change guards the nop reporting path: when the payload has no
check_run, the deduplicated dry-run results are written to the log at info level and the check-run/PR-comment reporting is skipped. So a scheduled or CLI full sync in nop mode now completes and prints its plan instead of dying after doing all the work. The webhook flow is untouched, and non-nop runs don't go through this path at all.#923 previously approached this by posting the results back to a PR via Actions env vars before it was closed. This PR is intentionally narrower: just stop crashing and put the plan in the log. Something like #923 could still layer nicer reporting on top later.
Added
handleResultscoverage: a nop run with a payload that lackscheck_runresolves and logs the results without touching the checks API, and a nop run with acheck_runstill completes the check run as before (that path had no coverage either).