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

Backslashes in comments in .forceignore produce warnings on deploy/retrieve #3127

Open
AndrewStopchenko-SO opened this issue Nov 26, 2024 · 3 comments

Comments

@AndrewStopchenko-SO
Copy link
Contributor

AndrewStopchenko-SO commented Nov 26, 2024

Summary

When .forceignore file contains backslashes \ in the comments (for whatever reason...), sf project retrieve start and sf project deploy start commands add multiple warning messages as below:

Warning: Your .forceignore file incorrectly uses the backslash ("\") as a folder separator; it should use the slash ("/") instead. The ignore rules will not work as expected until you fix this.

Why backslashes occurred in your .forceignore file?

When some files are failing to deploy, we happened to add ignore pattern and included the problematic filepath as a comment to that ignored pattern. And the original deployment failures output displayed filepath with backslashes (on Windows). 🙂

Steps To Reproduce

  • Generate project with Empty template, create default scratch org.
  • create a sample component (e.g. basic Apex class), deploy this component to the org.
  • update .forceignore file to include the following line at the end:

    # SAMPLE COMMENT WITH BACKSLASHES: force-app\

  • Try running the sf project retrieve start and sf project deploy start CLI commands in the VSCode Terminal (PowerShell 7), see the warning(s) in the terminal output. In my case, sf project retrieve start command produced 3 warning messages; sf project retrieve start produced 1 warning message.
    image
  • Remove the comment with backslashes, or, replace the basckslash \ with a slash / character, and run the sf project retrieve start CLI command again - no warnings produced.

Expected result

Backslashes in comments should be ignored, the warning should only react to baskslashes used in the ignored path patterns.

Actual result

Warning is displayed (even multiple times in case of retrieve operation).
This is especially annoying when running sf project retrieve start in the project where many components exist, then these messages are flooding the terminal buffer.

System Information

CLI:
@salesforce/cli/2.67.7 win32-x64 node-v22.11.0

Plugin Version:
@oclif/plugin-autocomplete 3.2.8 (core)
@oclif/plugin-commands 4.1.8 (core)
@oclif/plugin-help 6.2.16 (core)
@oclif/plugin-not-found 3.2.25 (core)
@oclif/plugin-plugins 5.4.15 (core)
@oclif/plugin-search 1.2.14 (core)
@oclif/plugin-update 4.6.10 (core)
@oclif/plugin-version 2.2.15 (core)
@oclif/plugin-warn-if-update-available 3.1.21 (core)
@oclif/plugin-which 3.2.17 (core)
@salesforce/cli 2.67.7 (core)
apex 3.6.2 (core)
api 1.3.2 (core)
auth 3.6.73 (core)
data 3.11.3 (core)
deploy-retrieve 3.15.11 (core)
info 3.4.18 (core)
limits 3.3.39 (core)
marketplace 1.3.4 (core)
org 5.1.4 (core)
packaging 2.9.0 (core)
schema 3.3.40 (core)
settings 2.4.4 (core)
sobject 1.4.45 (core)
telemetry 3.6.20 (core)
templates 56.3.29 (core)
trust 3.7.41 (core)
user 3.6.2 (core)
@salesforce/sfdx-scanner 4.7.0 (user)
SF ENV. VARS.
SF_AUTOUPDATE_DISABLE,true
SF_BINPATH,C:\Users\USER_NAME\AppData\Local\sf\client\bin\sf
SF_DISABLE_AUTOUPDATE,true
SF_UPDATE_INSTRUCTIONS,Use "npm update --global @salesforce/cli" to update npm-based installations.
Windows: true
Shell: powershell
Channel: stable

Diagnostics

✅ pass - salesforcedx plugin isn’t installed
✅ pass - you don't have any linked plugins
❌ unknown - using latest or latest-rc CLI version
✅ pass - [@salesforce/plugin-deploy-retrieve] sourceApiVersion matches apiVersion
✅ pass - [@salesforce/plugin-deploy-retrieve] default target DevHub max apiVersion matches default target org max apiVersion
✅ pass - [@salesforce/plugin-deploy-retrieve] sourceApiVersion matches default target org max apiVersion
✅ pass - can access: https://test.salesforce.com
✅ pass - can access: https://appexchange.salesforce.com/services/data
✅ pass - can access: https://developer.salesforce.com/media/salesforce-cli/sf/channels/stable/sf-win32-x64-buildmanifest

> sf version --verbose --json output:

{
  "architecture": "win32-x64",
  "cliVersion": "@salesforce/cli/2.67.7",
  "nodeVersion": "node-v22.11.0",
  "osVersion": "Windows_NT 10.0.19045",
  "rootPath": "C:\\Users\\USER_NAME\\AppData\\Local\\sf\\client\\2.67.7-3acb081",
  "shell": "powershell",
  "pluginVersions": [
    "@oclif/plugin-autocomplete 3.2.8 (core)",
    "@oclif/plugin-commands 4.1.8 (core)",
    "@oclif/plugin-help 6.2.16 (core)",
    "@oclif/plugin-not-found 3.2.25 (core)",
    "@oclif/plugin-plugins 5.4.15 (core)",
    "@oclif/plugin-search 1.2.14 (core)",
    "@oclif/plugin-update 4.6.10 (core)",
    "@oclif/plugin-version 2.2.15 (core)",
    "@oclif/plugin-warn-if-update-available 3.1.21 (core)",
    "@oclif/plugin-which 3.2.17 (core)",
    "@salesforce/cli 2.67.7 (core)",
    "apex 3.6.2 (core)",
    "api 1.3.2 (core)",
    "auth 3.6.73 (core)",
    "data 3.11.3 (core)",
    "deploy-retrieve 3.15.11 (core)",
    "info 3.4.18 (core)",
    "limits 3.3.39 (core)",
    "marketplace 1.3.4 (core)",
    "org 5.1.4 (core)",
    "packaging 2.9.0 (core)",
    "schema 3.3.40 (core)",
    "settings 2.4.4 (core)",
    "sobject 1.4.45 (core)",
    "telemetry 3.6.20 (core)",
    "templates 56.3.29 (core)",
    "trust 3.7.41 (core)",
    "user 3.6.2 (core)",
    "@salesforce/sfdx-scanner 4.7.0 (user)"
  ]
}
@WillieRuemmele
Copy link
Member

we probably just need to update the regex to exclude comments 💡

@WillieRuemmele WillieRuemmele added the help wanted Help wanted to implement this issue label Nov 26, 2024
@AndrewStopchenko-SO
Copy link
Contributor Author

AndrewStopchenko-SO commented Nov 26, 2024

we probably just need to update the regex to exclude comments 💡

I believe this is the place where it checks the whole .forceignore file's content for backslashes:
https://github.com/forcedotcom/source-deploy-retrieve/blob/main/src/resolve/forceIgnore.ts#L28

I am curious though why the warning "spams" multiple times in the terminal during the sf project retrieve start CLI command (on some larger projects)...

@WillieRuemmele
Copy link
Member

you're correct. I actually have that open and was modifying it now!!

it seems like every time the forceignore class is constructed, it scans the file for \, and emits the warning, during the deploy we check the file in different steps, so multiple warnings

I'm changing it so it goes line by line, and checks if it's a commented line # and includes \

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

No branches or pull requests

3 participants