Skip to content

Conversation

@kanushka
Copy link
Contributor

@kanushka kanushka commented Jul 7, 2025

Purpose

This pull request updates the build process to show warnings for missing environment variables instead of causing the build to fail. This allows processes like pull request checks, which lack configured environment variables, to complete successfully. The warning logs will still help developers identify any missing variables.

…turn missing variables and log warnings, improving build resilience.
@kanushka kanushka requested review from gigara and hevayo as code owners July 7, 2025 17:42
@gigara gigara requested a review from Copilot July 7, 2025 17:46
Copy link
Contributor

Copilot AI left a comment

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 updates the build process to warn on missing environment variables instead of failing, allowing builds to complete even when vars aren’t set.

  • Replaced exception-throwing for missing env vars with a warning log in webpack configs.
  • Modified createEnvDefinePlugin to return both envKeys and missingVars instead of throwing.
  • Added an initial log statement when fetching environment variables.

Reviewed Changes

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

File Description
workspaces/wso2-platform/wso2-platform-extension/webpack.config.js Replaced try/catch with destructuring of envKeys and missingVars; added warnings
workspaces/mi/mi-extension/webpack.config.js Same environment-handling update as WSO2 extension
workspaces/ballerina/ballerina-extension/webpack.config.js Same environment-handling update as WSO2 extension
common/scripts/env-webpack-helper.js Changed createEnvDefinePlugin to return missingVars instead of throwing
Comments suppressed due to low confidence (1)

common/scripts/env-webpack-helper.js:26

  • [nitpick] The JSDoc return type is generic; consider specifying a structured return type like @returns {{envKeys: Object, missingVars: string[]}} for better clarity.
 * @returns {Object} Object containing envKeys for webpack.DefinePlugin and missingVars array

console.warn(error.message);
console.warn('Continuing build with empty environment variables...');
envKeys = {};
console.log("Fetching values for environment variables...");
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

[nitpick] Using console.log for a routine build message can clutter output; consider using console.info or a dedicated logger so warnings remain prominent.

Suggested change
console.log("Fetching values for environment variables...");
console.info("Fetching values for environment variables...");

Copilot uses AI. Check for mistakes.
console.warn('Continuing build with empty environment variables...');
envKeys = {};
console.log("Fetching values for environment variables...");
const { envKeys, missingVars } = createEnvDefinePlugin(env);
Copy link

Copilot AI Jul 7, 2025

Choose a reason for hiding this comment

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

The same environment variable handling logic is duplicated across multiple webpack configs; consider extracting this into a shared utility to reduce duplication.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This log should be in the webpack, otherwise the rush build log won't show the output. That's why all the logs are duplicated in the webpack config files.

@sachiniSam sachiniSam merged commit 71f68a0 into wso2:main Jul 8, 2025
7 checks passed
@kanushka kanushka deleted the env-fix-2 branch July 17, 2025 13:02
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