Added Safety Check for ENV Variables #87192
Open
+17
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add Safety Checks for Critical Environment Variables in
fetchAPIThis PR improves the
fetchAPIutility by adding explicit validation for critical environment variables. Previously, missingGRAPHCMS_PROJECT_APIor auth tokens could lead to cryptic errors during runtime. With this change:GRAPHCMS_PROJECT_APIis validated at the start of the function.GRAPHCMS_DEV_AUTH_TOKENandGRAPHCMS_PROD_AUTH_TOKENare validated based on thepreviewflag.json.errors.Benefits
Example Error Messages After This PR
Missing GRAPHCMS_PROJECT_API environment variableMissing GRAPHCMS_DEV_AUTH_TOKEN environment variableMissing GRAPHCMS_PROD_AUTH_TOKEN environment variableThis enhancement increases the robustness of the API utility and follows best practices for handling critical environment dependencies.