Skip to content

Fix workflow failure when GCP_CREDENTIALS not configured#69

Draft
Copilot wants to merge 5 commits into
copilot/complete-tasks-autocompletefrom
copilot/fix-build-dependency-issues
Draft

Fix workflow failure when GCP_CREDENTIALS not configured#69
Copilot wants to merge 5 commits into
copilot/complete-tasks-autocompletefrom
copilot/fix-build-dependency-issues

Conversation

Copy link
Copy Markdown

Copilot AI commented Feb 14, 2026

The dump-ci-stats workflow fails with SyntaxError: Unexpected end of JSON input when GCP_CREDENTIALS secret is not configured. The script attempts to parse the empty environment variable before validating it exists.

Changes

  • Move GCP_CREDENTIALS validation before require() statement to prevent module loading when credentials aren't set
  • Exit gracefully (exit code 0) when credentials are empty, unset, or whitespace-only

Before:

const Monitoring = require('@google-cloud/monitoring');

// Check happens after require
if (!process.env.GCP_CREDENTIALS || process.env.GCP_CREDENTIALS.trim() === '') {
  process.exit(0);
}
const gcpCredentials = JSON.parse(process.env.GCP_CREDENTIALS);

After:

// Check happens before any requires
if (!process.env.GCP_CREDENTIALS || process.env.GCP_CREDENTIALS.trim() === '') {
  console.log('GCP_CREDENTIALS not set. Skipping metrics reporting.');
  process.exit(0);
}

const Monitoring = require('@google-cloud/monitoring');
const gcpCredentials = JSON.parse(process.env.GCP_CREDENTIALS);
Original prompt

Reference: https://github.com/Snapp949/agoric-sdk/actions/runs/22013178321/job/63610640249#step:6:1


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Move the GCP_CREDENTIALS validation before the require statement
to prevent module loading errors when the credential is not set.
This ensures graceful exit when GCP_CREDENTIALS is empty, unset,
or contains only whitespace.

Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix build dependency issues in project Fix workflow failure when GCP_CREDENTIALS not configured Feb 14, 2026
Copilot AI requested a review from Snapp949 February 14, 2026 07:10
@Snapp949
Copy link
Copy Markdown
Owner

Snapp949 commented Mar 2, 2026

Ty

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.

2 participants