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

EnvironmentCommandlet can log warnings into the middle of environment variables #531

Closed
hohwille opened this issue Aug 9, 2024 · 1 comment · Fixed by #541 or #559
Closed

EnvironmentCommandlet can log warnings into the middle of environment variables #531

hohwille opened this issue Aug 9, 2024 · 1 comment · Fixed by #541 or #559
Assignees
Labels
bug Something isn't working CLI IDEasy command-line-interface (parsing args, etc.) environment EnvironmentCommandlet, env variables, path, etc. logging

Comments

@hohwille
Copy link
Member

hohwille commented Aug 9, 2024

Expected behavior

As a IDEasy user, I want to setup my project environment in any shell anywhere with just the command ide so that I can start working seamlessly from there.

Actual behavior

Setting up the environment variables with ide commandlet can cause errors and even potentially security risks.
If variables cannot be evaluated, that should normally be logged as warning to notify the user about a problem.
However, the problem with EnvironmentCommandlet (ide env) is that here we are using the "log" as an "API" to the shell (bash or CMD) and send some kind of "code for execution".
Now, if some log message like Undefined variable ${UNDEFINED} in 'SOME' gets logged into this "code", that breaks the "API".
So most likely we have to control the log for this commandlet like we do in CompleteCommandlet.

Steps to reproduce (bug)

  1. add something like FOO=${BAR} ${SOME} ${UNDEFINED} to your ide.properties
  2. run ide command in that project.

I then get errors like this in bash:

bash: $'\E[93mUndefined': command not found
bash: $'\E[93mUndefined': command not found
bash: $'\E[93mUndefined': command not found

Comments/Hints:

See

System.out.print(candidate.text()); // enforce output via System.out even if logging is disabled

In EnvironmentCommandletTest we also have a lot of redundancy now for windows and non-windows case in case of info-logging and also I had to comment out the assertion method like this: log().hasEntries/*WithNothingElseInBetween*/(...).
To avoid the redundancies, we should manually build the expected VariableLine instances and then have an advanced assertion method that can take flags like boolean quoteValue and boolean omitExport.

Affected version:

  • OS: Windows (also Linux/Mac)
  • IDEasy: 2024.08.001-beta-SNAPSHOT
@hohwille hohwille added the bug Something isn't working label Aug 9, 2024
@github-project-automation github-project-automation bot moved this to 🆕 New in IDEasy board Aug 9, 2024
@hohwille hohwille self-assigned this Aug 14, 2024
@hohwille hohwille added this to the release:2024.09.001 milestone Aug 14, 2024
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in IDEasy board Aug 20, 2024
@hohwille
Copy link
Member Author

Still not fix by PR #541.
@hohwille what are you doing 😵😆

$ ideasy env
Variable IDE_ROOT is set to 'D:\projects\_ide' but for your project 'IDEasy' the path 'D:\projects' would have been expected.
AWS_CONFIG_FILE=D:\projects\IDEasy\conf\aws\config
...

So this is what I predicted that still logs can be produced in the constructor of IdeContext causing this problem.
Hence, this is still not fixed.
Further, I made another bug here:

$ ideasy -d env
Variable IDE_ROOT is set to 'D:\projects\_ide' but for your project 'IDEasy' the path 'D:\projects' would have been expected.
Configuration directory C:\Users\hohwille\.ide does not exist.
Running commandlet EnvironmentCommandlet[env]
AWS_CONFIG_FILE=D:\projects\IDEasy\conf\aws\config
... env variables but no more debug logging here ...

So PR #541 now disables debug logging even if -d or --debug was present.

@hohwille hohwille reopened this Aug 26, 2024
hohwille added a commit to hohwille/IDEasy that referenced this issue Aug 26, 2024
@hohwille hohwille added environment EnvironmentCommandlet, env variables, path, etc. CLI IDEasy command-line-interface (parsing args, etc.) logging labels Aug 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working CLI IDEasy command-line-interface (parsing args, etc.) environment EnvironmentCommandlet, env variables, path, etc. logging
Projects
Status: ✅ Done
1 participant