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

SFDX replacements: not able to replace with blank value #2070

Closed
benben-user opened this issue Apr 16, 2023 · 9 comments
Closed

SFDX replacements: not able to replace with blank value #2070

benben-user opened this issue Apr 16, 2023 · 9 comments
Labels
feature Issue or pull request for a new feature

Comments

@benben-user
Copy link

Im using the replacements feature, all work as expected only issue i cannot replace some text with blank value.

My use case is to replace NameSpace prefix with blank in order to deploy my code to another environment that do not have NameSpace .

Here is an example :

"replacements": [
    {
      "filename": "/force-app/main/default/classes/myHelper.cls",
      "stringToReplace": "myNS__",
      "replaceWithEnv": "BLANK"
    }
  ]

.env
BLANK =

My cli commend is
dotenv -e .env sfdx force source push

which results with :

 Component conversion failed: "BLANK" is in sfdx-project.json as a value for "replaceWithEnv" property, but it's not set in your environment.
@benben-user benben-user added the investigating We're actively investigating this issue label Apr 16, 2023
@github-actions
Copy link

Thank you for filing this issue. We appreciate your feedback and will review the issue as soon as possible. Remember, however, that GitHub isn't a mechanism for receiving support under any agreement or SLA. If you require immediate assistance, contact Salesforce Customer Support.

@mshanemc
Copy link
Contributor

oh, interesting. Would an empty string '' work?

@mshanemc mshanemc added the more information required Issue requires more information or a response from the customer label Apr 17, 2023
@pgonzaleznetwork
Copy link

@mshanemc I'm not the OP but I can confirm this works with a string that contains a space, like this

export HAPPY_SOUP_URL=' '

However, if it's a real entry empty string, like this

export HAPPY_SOUP_URL=' '

The command fails with

Error (1): Component conversion failed: "HAPPY_SOUP_URL" is in sfdx-project.json as a value for "replaceWithEnv" property, but it's not set in your environment.

@benben-user
Copy link
Author

benben-user commented Apr 17, 2023

oh, interesting. Would an empty string '' work?

Well not for my (Mac).
Also my use case is to replace NS__ so a space will not do the job.
I guess we can use some CONSTE like __BLANK__ and the code (sfdx) will use "" as the replacement and not consider that as an empty env parameter

@mshanemc
Copy link
Contributor

ugh. The downside of changing this would be making it hard to detect the very real mistake of missing envs, which seems backward.

The "cleanest" thing might be to have a new json prop in the replacements to make it clear you want to remove the matched value.

@mshanemc mshanemc added feature Issue or pull request for a new feature and removed more information required Issue requires more information or a response from the customer investigating We're actively investigating this issue labels Apr 17, 2023
@github-actions
Copy link

Thank you for filing this feature request. We appreciate your feedback and will review the feature at our next grooming or sprint planning session. We prioritize feature requests with more upvotes and comments.

@git2gus
Copy link

git2gus bot commented Apr 17, 2023

This issue has been linked to a new work item: W-13047969

@shetzel
Copy link
Contributor

shetzel commented Jun 27, 2023

I'm on a mac using zsh and both of these worked for me in replacements:

  1. export BLANK='' (empty string)
  2. export BLANK= (pretty sure zsh also sets this to an empty string)

Maybe this is specific to the shell? Regardless, the fix will resolve an env var that is not found as an empty string (when explicitly set in the replacements section)

@shetzel
Copy link
Contributor

shetzel commented Jul 6, 2023

This is now in the latest CLIs: sfdx 7.208.10 / sf 1.85.8

@shetzel shetzel closed this as completed Jul 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Issue or pull request for a new feature
Projects
None yet
Development

No branches or pull requests

4 participants