Skip to content

fix(e2b-env-var): use isTruthy and getEnv#1228

Merged
icecrasher321 merged 1 commit intostagingfrom
fix/env-var-e2b
Sep 3, 2025
Merged

fix(e2b-env-var): use isTruthy and getEnv#1228
icecrasher321 merged 1 commit intostagingfrom
fix/env-var-e2b

Conversation

@icecrasher321
Copy link
Collaborator

Summary

Use isTruthy helper + getEnv for client side variable fetches.

Type of Change

  • Bug fix

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel
Copy link

vercel bot commented Sep 3, 2025

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

Project Deployment Preview Comments Updated (UTC)
sim Building Building Preview Comment Sep 3, 2025 3:02am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
docs Skipped Skipped Sep 3, 2025 3:02am

@icecrasher321 icecrasher321 merged commit b74ab46 into staging Sep 3, 2025
3 of 4 checks passed
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

Greptile Summary

This PR refactors environment variable access for the E2B feature across two critical files in the codebase. The changes replace direct environment variable access patterns with centralized utility functions from the @/lib/env module.

In apps/sim/app/api/function/execute/route.ts, the code moves from process.env.E2B_ENABLED === 'true' to using isTruthy(env.E2B_ENABLED). This leverages the existing env configuration object that provides type safety and validation through zod schemas.

In apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/workflow-block.tsx, the change is more significant as it switches from env.NEXT_PUBLIC_E2B_ENABLED === 'true' to isTruthy(getEnv('NEXT_PUBLIC_E2B_ENABLED')). The getEnv function is particularly important here as it first attempts to retrieve variables using next-runtime-env (for Docker runtime injection) and falls back to process.env if needed.

These changes align with the codebase's established pattern of environment variable management. The isTruthy helper function provides more robust boolean evaluation, handling various truthy string representations ('true', '1', 'yes', etc.) beyond simple string equality. This standardization improves the application's compatibility with Docker deployments where environment variables need to be injected at runtime rather than build time, especially for client-side variables prefixed with NEXT_PUBLIC_.

The refactoring enhances type safety through the existing zod validation schemas in the env configuration and ensures consistent environment variable access patterns across both server-side API routes and client-side React components.

Confidence score: 5/5

  • This PR is safe to merge with minimal risk as it standardizes existing functionality without changing behavior
  • Score reflects straightforward refactoring using well-established utility functions with no complex logic changes
  • No files require special attention as both changes follow identical, proven patterns

2 files reviewed, no comments

Edit Code Review Bot Settings | Greptile

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.

1 participant