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: Inaccurate path resolution in Boot #9309

Closed
sk757a opened this issue Dec 9, 2024 · 13 comments · Fixed by #9317
Closed

Bug: Inaccurate path resolution in Boot #9309

sk757a opened this issue Dec 9, 2024 · 13 comments · Fixed by #9317
Labels
missing feature Reported issue which is not a bug but needs to be implemented

Comments

@sk757a
Copy link

sk757a commented Dec 9, 2024

PHP Version

8.3

CodeIgniter4 Version

4.5.5

CodeIgniter4 Installation Method

Composer (as dependency to an existing project)

Which operating systems have you tested for this bug?

Windows

Which server did you use?

cli

Database

No response

What happened?

spark prints "" and nothing else.

Steps to Reproduce

  1. Set $writableDirectory in Paths to non-existent folder
  2. Run spark

Expected Output

At least more meaningful error message.

Anything else?

When using the realpath function, if there is no actual path in the file system, false is returned. Which is then converted to an empty string when concatenated. The result path is pointing to the root.

@sk757a sk757a added the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 9, 2024
@michalsn
Copy link
Member

By default in the production environment errors are not displayed. Please set CI_ENVIRONMENT = development in the .env file to see the detailed error.

@michalsn michalsn removed the bug Verified issues on the current code behavior or pull requests that will fix them label Dec 10, 2024
@sk757a
Copy link
Author

sk757a commented Dec 10, 2024

I understand and know this, but what is the point of not showing error messages in the terminal? It turns out that the terminal user in the production environment must be either an attacker or a telepath. It is unclear and unfriendly in my opinion.

@sk757a
Copy link
Author

sk757a commented Dec 10, 2024

By default in the production environment errors are not displayed. Please set CI_ENVIRONMENT = development in the .env file to see the detailed error.

I should have written about the environment, of course. My mistake.

@michalsn michalsn added the missing feature Reported issue which is not a bug but needs to be implemented label Dec 10, 2024
@paulbalandan
Copy link
Member

This seems to be an issue with display_errors again which is fixed in 4.6. If you have environment set to production and display_errors set to 1 in boot, errors will appear as usual.

@michalsn
Copy link
Member

I don't believe that OP wants to change any settings to see errors in the cli.

@michalsn
Copy link
Member

Oh... I just spotted the full description of the label I assigned to this issue, so I am removing it now.

While this may be inconvenient, we rely on the settings from the given environment to display errors.

@michalsn michalsn removed the missing feature Reported issue which is not a bug but needs to be implemented label Dec 11, 2024
@sk757a
Copy link
Author

sk757a commented Dec 11, 2024

The problem is that there is one setting, but two interfaces - web and cli. The point of hiding the output of confidential information, in my opinion, exists only in the case of web. Okay, I get it. Thanks.

@sk757a sk757a closed this as completed Dec 11, 2024
@michalsn
Copy link
Member

Yes, I understand your point. But in some cases, this can be dangerous. We can't be sure what users will do with spark. It can be run via cron and log the output of the command - which would potentially expose sensitive details.

@sk757a
Copy link
Author

sk757a commented Dec 11, 2024

I didn't think about the cron and now completely agree.
But from another point of view, a program in any environment should not silently fail. The user should be able to diagnose and to fix or report the problem. Usually in such situations, log file analysis helps, but ironically not in this case, because log file cannot be written. There is no error message, no entry in log file and no solution.

@kenjis
Copy link
Member

kenjis commented Dec 11, 2024

@sk757a You could send a PR to check the real path in

define('WRITEPATH', realpath(rtrim($paths->writableDirectory, '\\/ ')) . DIRECTORY_SEPARATOR);

@kenjis
Copy link
Member

kenjis commented Dec 11, 2024

@paulbalandan @michalsn This is a special case, because when $writableDirectory is wrong, CI4 cannot log errors.
So there is no clue to debug.
Therefore I think if a PR that checks WRITEPATH comes, we should accept it.

@michalsn
Copy link
Member

Okay, let's reopen it then. What a rollercoaster 😅

@michalsn michalsn added the missing feature Reported issue which is not a bug but needs to be implemented label Dec 11, 2024
@michalsn michalsn reopened this Dec 11, 2024
@sk757a
Copy link
Author

sk757a commented Dec 13, 2024

Thank you guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
missing feature Reported issue which is not a bug but needs to be implemented
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants