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

[BUG] In debug bundle, many extra backslashes appear in Windows paths when a command fails #1408

Closed
ryanlink opened this issue Apr 12, 2024 · 4 comments

Comments

@ryanlink
Copy link
Contributor

ryanlink commented Apr 12, 2024

Describe the bug
When using --debug to generate output from fossa analyze to troubleshoot a command failure in the build process on a Windows machine, the output contains many redundant backslashes, presumably as escape chars:

Attempted to run the command 'C:\\\\\\\\Program Files\\\\\\\\apache-maven-3.9.6\\\\\\\\bin\\\\\\\\mvn -v'\\\\n inside the working directory 'C:\\\\\\\\FOSSA\\\\\\\\pfmService\\\\\\\\access-center\\\\\\\\',\\\\n but failed, because the command exited with code '1'.\\\\n\\\\n Often, this kind of error is caused by the project not being ready to build;\\\\n please ensure that the project at 'C:\\\\\\\\FOSSA\\\\\\\\pfmService\\\\\\\\access-center\\\\\\\\'\\\\n builds successfully before running fossa

To Reproduce
Steps to reproduce the behavior:

  1. Run fossa analyze ...
  2. See error

Expected behavior
This error should not contain extraneous backslashes.

Debug bundle
Please run fossa with the --debug flag and attach the resulting fossa.debug.json.gz file here.

Additional context
I asked ChatGPT to analyze the code in https://github.com/fossas/fossa-cli/blob/master/src/Effect/Exec.hs and explain the backslashes. Here's the response:

It seems that the extra backslashes are appearing in the error message because of the way the paths are constructed and processed in the code. Let's break down the possible reasons:

  1. Path Construction: In Haskell's Path module, paths are constructed using a type-safe representation, which ensures that file paths are correctly formed. However, when converting these paths to strings for display, the conversion process may introduce additional escape characters if not handled properly.

  2. Text Encoding: When converting between Text and String types, especially with file paths, encoding issues may arise, leading to unexpected characters or escape sequences being introduced.

  3. Text Interpolation: In the error message generation, if interpolation is done incorrectly or if there are inconsistencies in handling string literals and interpolated values, extra backslashes might appear.

To address this issue, you should ensure that:

  • When constructing paths from Path types to strings, you're using appropriate functions provided by the Path module to convert them without introducing escape characters unnecessarily.

  • When interpolating paths into strings or error messages, ensure that the escaping is handled correctly. This might involve using functions like toFilePath from the Path module or escaping special characters explicitly if needed.

  • Double-check any custom text processing or interpolation functions to ensure they're handling paths and strings correctly, without inadvertently adding extra backslashes.

By carefully reviewing the code where paths are constructed, converted, and interpolated, you should be able to identify and resolve the issue causing the extra backslashes in the error messages.

Copy link

Thank you @ryanlink for creating this issue. If this is in regards to a defect, product question or feature request: you should use our support portal at https://support.fossa.com to file a request, as you would receive more immediate support.

@ryanlink ryanlink changed the title [BUG] In debug bundle, a ton of extra backslashes appear in Windows paths when a command fails [BUG] In debug bundle, many extra backslashes appear in Windows paths when a command fails Apr 12, 2024
@ryanlink
Copy link
Contributor Author

ryanlink commented Apr 12, 2024

Debug bundle
fossa.debug (25).json.gz

@ryanlink
Copy link
Contributor Author

Note that these redundant backslashes do not occur in fossa-analyze-scan-summary.txt:

  Warn: Command: `mvn` not suitable
  Running with args: `-v` resulted in a non-zero exit code

    Warn: Command execution failed
      Attempted to run the command 'mvn -v'
      inside the working directory 'D:\AINow\OTA1_3_22\backend\ainow-cloud-service\',
      but failed, because the command exited with code '1'.

      Often, this kind of error is caused by the project not being ready to build;
      please ensure that the project at 'D:\AINow\OTA1_3_22\backend\ainow-cloud-service\'
      builds successfully before running fossa.

      The logs for the command are listed below.
      They will likely provide guidance on how to resolve this error.
      Command did not write a standard log.

      Command error log:
        mvn: startProcess: does not exist (No such file or directory)
    Support: If you believe this to be a defect, please report a bug to FOSSA support at https://support.fossa.com

@ryanlink
Copy link
Contributor Author

Closing, filed as internal Jira ticket https://fossa.atlassian.net/browse/ANE-1638

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

1 participant