Fix: initial state handling for env variables in preflight script#7670
Conversation
Summary of ChangesHello @mskorokhodov, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request addresses a bug in the preflight script's environment variable handling. It refines how the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
🚀 Snapshot Release (
|
| Package | Version | Info |
|---|---|---|
@graphql-hive/yoga |
0.47.3-alpha-20260210111259-7f150794eb70b29aabba619c601745efd1dec2d1 |
npm ↗︎ unpkg ↗︎ |
hive |
9.4.0-alpha-20260210111259-7f150794eb70b29aabba619c601745efd1dec2d1 |
npm ↗︎ unpkg ↗︎ |
|
🐋 This PR was built and pushed to the following Docker images: Targets: Platforms: Image Tag: |
6305604 to
7f15079
Compare
💻 Website PreviewThe latest changes are available as preview in: https://pr-7670.hive-landing-page.pages.dev |
There was a problem hiding this comment.
Code Review
The pull request addresses an issue with the initial state handling of environment variables within the preflight script. The change ensures that the env.variables object is properly initialized, preventing potential runtime errors in the worker script when env or env.variables might be null or undefined. The suggested fix correctly handles null and undefined values for env?.variables by using the nullish coalescing operator.
| /* javascript */ ` | ||
| const env = ${JSON.stringify(env)}; | ||
| const env = { | ||
| variables: ${JSON.stringify(env?.variables)} || {}, |
There was a problem hiding this comment.
The current implementation uses || {} after JSON.stringify(env?.variables). If env?.variables is null, JSON.stringify(null) evaluates to the string "null". The expression then becomes "null" || {}, which results in variables: "null" in the worker script. This is incorrect as variables is expected to be an object (Record<string, string>) according to the LaboratoryEnv interface, and will lead to runtime errors when attempting to access properties on it.
To correctly handle both null and undefined values for env?.variables and ensure an empty object is used as a fallback, apply the nullish coalescing operator (??) directly to env?.variables before stringifying.
| variables: ${JSON.stringify(env?.variables)} || {}, | |
| variables: ${JSON.stringify(env?.variables ?? {})}, |
Background
Description
Checklist