Skip to content

fix(settings): handle nop mode results when check run is missing#1018

Open
tdabasinskas wants to merge 4 commits into
github-community-projects:main-enterprisefrom
datolabs-io:fix/nop-full-sync-check-run
Open

fix(settings): handle nop mode results when check run is missing#1018
tdabasinskas wants to merge 4 commits into
github-community-projects:main-enterprisefrom
datolabs-io:fix/nop-full-sync-check-run

Conversation

@tdabasinskas

Copy link
Copy Markdown

Fixes #818.

syncInstallation builds a minimal context whose payload only contains installation, but the nop branch of handleResults unconditionally reads payload.check_run.id and payload.repository.owner.login (and payload.check_run.check_suite.pull_requests when CREATE_PR_COMMENT is 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 handleResults coverage: a nop run with a payload that lacks check_run resolves and logs the results without touching the checks API, and a nop run with a check_run still completes the check run as before (that path had no coverage either).

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.
Copilot AI review requested due to automatic review settings July 11, 2026 09:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in handleResults to log results and skip check-run/PR-comment reporting when payload.check_run is missing.
  • Add unit tests covering handleResults behavior for both “no check_run” (full sync) and “has check_run” (webhook) nop contexts.

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.

Comment thread lib/settings.js Outdated
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread lib/settings.js Outdated
Comment thread lib/settings.js
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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread lib/settings.js
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dry run not working on Pull request using GitHub Actions workflow

2 participants