Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 24, 2025

Problem

The generate script (core/scripts/generate.cjs) currently throws errors when required BigCommerce environment variables are not configured:

Error: Missing store hash
Error: Missing storefront token

This prevents builds from completing during initial development setup or in CI/CD environments where store-specific credentials aren't available, making onboarding more difficult for new developers.

Solution

Updated the generate script to use a public fallback endpoint when environment variables are missing, while preserving existing behavior when they are configured.

Key Changes

  1. Fallback Endpoint: When BIGCOMMERCE_STORE_HASH is not set, the script now uses the public endpoint https://cxm-prd.bigcommerceapp.com/api/graphql-schema instead of throwing an error.

  2. Conditional Authorization: The Authorization: Bearer {token} header is only included when a storefront token is available, allowing the public endpoint to work without authentication.

  3. Graceful Degradation: Functions getStoreHash() and getToken() now return null instead of throwing errors when environment variables are missing.

Behavior

Without environment variables:

// Uses public endpoint for schema introspection
endpoint: 'https://cxm-prd.bigcommerceapp.com/api/graphql-schema'
headers: {} // No authorization required

With environment variables (unchanged):

// Uses store-specific endpoint with authentication
endpoint: 'https://store-{hash}.mybigcommerce.com/graphql'
headers: { Authorization: 'Bearer {token}' }

Benefits

  • ✅ Builds can complete without any BigCommerce environment variables
  • ✅ Easier onboarding for new developers
  • ✅ CI/CD pipelines work without store credentials
  • ✅ No breaking changes to existing configured environments
  • ✅ Generated GraphQL types remain valid for development

This change allows developers to get started immediately with pnpm run dev or pnpm run build without needing to configure store credentials first, while still supporting the full store-specific functionality once environment variables are properly set up.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • cxm-prd.bigcommerceapp.com
    • Triggering command: node scripts/generate.cjs (dns block)
    • Triggering command: curl -I REDACTED (dns block)
    • Triggering command: nslookup cxm-prd.bigcommerceapp.com (dns block)
  • googlechromelabs.github.io
    • Triggering command: node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chrome-headless-shell-linux64.zip
    • Triggering command: node install.mjs (http block)
  • store-test.mybigcommerce.com
    • Triggering command: node ./scripts/generate.cjs (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@vercel
Copy link

vercel bot commented Aug 24, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
catalyst-b2b Ready Ready Preview Comment Aug 24, 2025 5:16am
catalyst-canary Ready Ready Preview Comment Aug 24, 2025 5:16am
3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
catalyst Ignored Ignored Aug 24, 2025 5:16am
catalyst-au Ignored Ignored Aug 24, 2025 5:16am
catalyst-uk Ignored Ignored Aug 24, 2025 5:16am

@changeset-bot
Copy link

changeset-bot bot commented Aug 24, 2025

⚠️ No Changeset found

Latest commit: a8963bd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copilot AI changed the title [WIP] Update the generate script to be tolerant to cases where environment variables have not yet been configured by getting the GraphQL schema from a public endpoint at https://cxm-prd.bigcommerceapp.com/api/graphql-schema (a normal introspection request ca... Make generate script tolerant to missing environment variables with fallback endpoint Aug 24, 2025
Copilot AI requested a review from bookernath August 24, 2025 05:01
Copilot finished work on behalf of bookernath August 24, 2025 05:01
@bookernath
Copy link
Contributor

@copilot fix the build failure due to prettier rules; you can pnpm run lint -- --fix m@bigcommerce/catalyst-core:lint
cache miss, executing 3
a**bc000dab38fd

@bigcommerce/catalyst-core@..0 lint /home/runner/work/catalyst/catalyst/core
next lint --max-warnings=0

next lint is deprecated and will be removed in Next.js ***6.
For new projects, use create-next-app to choose your preferred linter.
For existing projects, migrate to the ESLint CLI:
npx @next/codemod@canary next-lint-to-eslint-cli .

Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

./scripts/generate.cjs
47:*** Warning: Delete ···· prettier/prettier
50:*** Warning: Delete ···· prettier/prettier

info - Need to disable some ESLint rules? Learn more here: https://nextjs.org/docs/app/api-reference/config/eslint#disabling-rules
 ELIFECYCLE  Command failed with exit code ***.

Copy link
Contributor Author

Copilot AI commented Aug 24, 2025

@copilot fix the build failure due to prettier rules; you can pnpm run lint -- --fix m@bigcommerce/catalyst-core:lint
cache miss, executing 3
a**bc000dab38fd

...

Fixed the prettier formatting issues by running ESLint with the --fix flag. Removed trailing whitespace from lines 47 and 50 in the generate.cjs file. (a8963bd)

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • googlechromelabs.github.io
    • Triggering command: node install.mjs (dns block)
  • https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.55/linux64/chrome-linux64.zip
    • Triggering command: node install.mjs (http block)

If you need me to access, download, or install something from one of these locations, you can either:

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