Skip to content

Fix workflow failure when GCP_CREDENTIALS secret is unset#67

Draft
Copilot wants to merge 7 commits into
copilot/complete-tasks-autocompletefrom
copilot/fix-action-step-error
Draft

Fix workflow failure when GCP_CREDENTIALS secret is unset#67
Copilot wants to merge 7 commits into
copilot/complete-tasks-autocompletefrom
copilot/fix-action-step-error

Conversation

Copilot AI commented Feb 14, 2026

Copy link
Copy Markdown

The "Dump GH CI Stats" workflow fails with SyntaxError: Unexpected end of JSON input when the GCP_CREDENTIALS secret is not configured, as JSON.parse('') throws on empty strings.

Changes

  • dump-ci-stats-to-gcp-metrics.cjs: Validate credentials before parsing, exit gracefully if unset
  • gcp-monitoring.cjs: Same validation, exports stub functions to prevent import failures

Both scripts now:

  1. Check for empty/whitespace-only values before parsing
  2. Wrap JSON.parse() in try-catch for malformed JSON
  3. Load @google-cloud/monitoring only after validation succeeds
// Before
const gcpCredentials = JSON.parse(process.env.GCP_CREDENTIALS);

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

let gcpCredentials;
try {
  gcpCredentials = JSON.parse(process.env.GCP_CREDENTIALS);
} catch (error) {
  console.error('Failed to parse GCP_CREDENTIALS:', error.message);
  process.exit(0);
}

Since these are optional monitoring features, workflows now skip metrics reporting when credentials are unavailable rather than failing.

Original prompt

Reference: https://github.com/Snapp949/agoric-sdk/actions/runs/22012754432/job/63609548053#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.

Copilot AI and others added 6 commits February 14, 2026 06:36
Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
…rors

Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
Co-authored-by: Snapp949 <173113150+Snapp949@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix action step error in workflow Fix workflow failure when GCP_CREDENTIALS secret is unset Feb 14, 2026
Copilot AI requested a review from Snapp949 February 14, 2026 06:43
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