Skip to content

Fix syncing parent env vars for non-preview deployments #2131

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 2, 2025

Conversation

nicktrn
Copy link
Collaborator

@nicktrn nicktrn commented May 30, 2025

If there are only parent env vars to sync and this isn't a preview deployment, we shouldn't try to sync at all.

Copy link

changeset-bot bot commented May 30, 2025

🦋 Changeset detected

Latest commit: fde79ca

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

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

Copy link
Contributor

coderabbitai bot commented May 30, 2025

Walkthrough

This update introduces a new patch changeset file documenting a fix related to the syncEnvVars functionality for non-preview deployments, serving as metadata rather than code. In the CLI deployment command, the logic for determining when to synchronize environment variables is streamlined by simplifying conditions and tying parent environment variable syncing explicitly to branch environments. The syncEnvVarsWithServer function is simplified to return API results directly, and error handling is refined to provide more detailed feedback. Additionally, a clarifying comment is added in the webapp route to explain when parent variable synchronization occurs, with no changes to logic or exported entities.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ff157e5 and fde79ca.

📒 Files selected for processing (3)
  • .changeset/witty-cherries-tan.md (1 hunks)
  • apps/webapp/app/routes/api.v1.projects.$projectRef.envvars.$slug.import.ts (1 hunks)
  • packages/cli-v3/src/commands/deploy.ts (5 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/cli-v3/src/commands/deploy.ts (3)
packages/cli-v3/src/commands/workers/build.ts (1)
  • syncEnvVarsWithServer (456-470)
apps/webapp/app/v3/services/createDeploymentBackgroundWorker.server.ts (1)
  • deployment (146-164)
packages/cli-v3/src/utilities/cliOutput.ts (1)
  • chalkError (24-26)
⏰ Context from checks skipped due to timeout of 90000ms (25)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (9, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (10, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 10)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 10)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 10)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
packages/cli-v3/src/commands/deploy.ts (7)

223-223: Minor formatting improvement.

Adding a blank line after the branch assignment improves code readability by separating logical sections.


356-358: Excellent logic simplification and fix for the core issue.

The simplified condition now explicitly ties parent environment variable syncing to branch environments, which aligns perfectly with the PR objective to fix syncing for non-preview deployments. The use of optional chaining makes the code more concise and readable.


370-377: Good improvement to capture full API response.

Updating the function call to capture the complete upload result instead of just a boolean enables better error handling and more detailed feedback to users.


379-379: Correct update to match new function return type.

The condition properly checks uploadResult.success to match the updated syncEnvVarsWithServer function that now returns the full API response object.


385-385: Enhanced error messaging with detailed feedback.

Including uploadResult.error in the error message provides users with more specific information about what went wrong during environment variable synchronization.


630-635: Function simplification improves error handling capabilities.

The simplified implementation that returns the full API result directly enables the calling code to access detailed error information, which is a significant improvement over the previous boolean-only approach.


665-665: Minor formatting consistency improvement.

Removing the trailing period from the error message formatting creates more consistent error output styling.

apps/webapp/app/routes/api.v1.projects.$projectRef.envvars.$slug.import.ts (1)

50-50: Excellent clarifying comment that aligns with the CLI changes.

This comment perfectly documents the business logic that parent variables are only synchronized for branch environments, which matches the explicit branch requirement added in the CLI deploy command.

.changeset/witty-cherries-tan.md (1)

1-6: Well-documented changeset for the fix.

The changeset properly documents this as a patch-level fix with a clear, concise description that accurately reflects the changes made to the syncEnvVars functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@matt-aitken matt-aitken merged commit 84d8fb5 into main Jun 2, 2025
33 checks passed
@matt-aitken matt-aitken deleted the fix/parent-env-sync branch June 2, 2025 09:40
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