Skip to content
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

[cli] optional override of existing environment variables #11348

Merged
merged 7 commits into from Apr 10, 2024

Conversation

mountainash
Copy link
Contributor

@mountainash mountainash commented Mar 29, 2024

Why

Closes #11130

Changelog

Added --force argument to upsert existing environment variables (#11130)

References

Copy link

changeset-bot bot commented Mar 29, 2024

🦋 Changeset detected

Latest commit: 7f785fd

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

This PR includes changesets to release 1 package
Name Type
vercel Patch

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

@EndangeredMassa EndangeredMassa left a comment

Choose a reason for hiding this comment

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

Thanks for the detailed PR with tests! I think we can accept this change if we make some tweaks.

packages/cli/src/commands/env/add.ts Outdated Show resolved Hide resolved
packages/cli/src/util/env/add-env-record.ts Outdated Show resolved Hide resolved
@EndangeredMassa
Copy link
Contributor

I made some tweaks to flesh out the new option.

Copy link
Contributor Author

@mountainash mountainash left a comment

Choose a reason for hiding this comment

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

All valid to me. Thanks. 🙏

@EndangeredMassa EndangeredMassa added the pr: automerge Automatically merge the PR when checks pass label Apr 10, 2024
@kodiakhq kodiakhq bot merged commit 7259a32 into vercel:main Apr 10, 2024
6 of 8 checks passed
@EndangeredMassa
Copy link
Contributor

Thanks @mountainash!

TooTallNate pushed a commit that referenced this pull request Apr 10, 2024
## Why

Closes #11130

## Changelog

Added `--force` argument to upsert existing environment variables (#11130)

## References

- Vercel API `/v10/projects/{idOrName}/env` https://vercel.com/docs/rest-api/endpoints/projects#create-one-or-more-environment-variables
EndangeredMassa pushed a commit that referenced this pull request Apr 11, 2024
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## vercel@34.0.0

### Major Changes

- Disables promotion of preview deployments
([#11411](#11411))

### Patch Changes

- Always set `projectSettings.nodeVersion` in `vc deploy`
([#11351](#11351))

- [cli] optional override of existing environment variables with --force
([#11348](#11348))

## @vercel/client@13.2.0

### Minor Changes

- Always use v13 of create deployment API endpoint
([#11351](#11351))

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
@crbraun
Copy link

crbraun commented Apr 11, 2024

Is it possible this caused an issue using env variables? Just recently I am no longer able to call my Dynamo endpoint

Error fetching item from DynamoDB UnrecognizedClientException: The security token included in the request is invalid

   const dynamoClient: DynamoDBClient = new DynamoDBClient({region: AWS_REGION});
    // Use GetItemCommand to get the item from the table
    const {Item} = await dynamoClient.send(new GetItemCommand(params));

Works in my local env. Verified my env variables have not changed. Both AWS_SECRET_ACCESS_KEY and AWS_ACCESS_KEY_ID exist and are populated with the correct key.

@EndangeredMassa
Copy link
Contributor

@crbraun what version of the Vercel CLI (vercel) are you using? Can you verify that the env var is available at that time in your code by logging it out?

@crbraun
Copy link

crbraun commented Apr 11, 2024

@crbraun what version of the Vercel CLI (vercel) are you using? Can you verify that the env var is available at that time in your code by logging it out?

I did verify that AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are present. Oddly there there is a AWS_SESSION_TOKEN present in the environment which my application never sets. I expect this is the issue. But I am not sure how this got in the environment as I do not have this variable set anywhere.

@crbraun
Copy link

crbraun commented Apr 11, 2024

I was able to work around this issue by adding an empty AWS_SESSION_TOKEN env variable to my environment. I expect there is something wrong with the vercel deployer as it seems to be setting an AWS_SESSION_TOKEN when there is none present in the configuration.

@EndangeredMassa
Copy link
Contributor

Hrm. I don't think that should be happening. If you open a support case, we can look into it. https://vercel.com/contact

@crbraun
Copy link

crbraun commented Apr 11, 2024

It doesn't look like I am allowed to create a support ticket

Visit our Community for further help or create a paid account for dedicated Builds & Deployments → Builds support.

I have it worked around for now, but I am fairly certain there was a recent change in vercel that was deployed today that caused this issue. Let me know if there is a way I can log an issue with support, be glad to do so.

-- Thanks

@onsclom onsclom mentioned this pull request Apr 12, 2024
onsclom added a commit that referenced this pull request Apr 12, 2024
The changes between #11348 and
#11394 were incompatible, causing
this type error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: automerge Automatically merge the PR when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vercel cli has not option to update existing values
3 participants