CodeIgniter Forums
Database Exception showing TRACE even in PROD - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: Database Exception showing TRACE even in PROD (/showthread.php?tid=83800)



Database Exception showing TRACE even in PROD - encodedigital - 10-13-2022

hi All,
I deliberately turned off my MySQL to check how application (API) behaves, but I am seeing application trace even when I am in PRODUCTION model. I am using CodeIgniter 4 for API.
Please see complete Curl result as below.
This is definitely not secure. Could you please advise how to avoid trace in exception response. I tried try catch in my code, but this exception override my catch exception.
Code:
{
    "title": "CodeIgniter\\Database\\Exceptions\\DatabaseException",
    "type": "CodeIgniter\\Database\\Exceptions\\DatabaseException",
    "code": 500,
    "message": "Unable to connect to the database.\r\nMain connection [MySQLi]: No connection could be made because the target machine actively refused it",
    "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Database\\BaseConnection.php",
    "line": 418,
    "trace": [
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Database\\BaseConnection.php",
            "line": 588,
            "function": "initialize",
            "class": "CodeIgniter\\Database\\BaseConnection",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Database\\BaseBuilder.php",
            "line": 1585,
            "function": "query",
            "class": "CodeIgniter\\Database\\BaseConnection",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Validation\\Rules.php",
            "line": 142,
            "function": "get",
            "class": "CodeIgniter\\Database\\BaseBuilder",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Validation\\Validation.php",
            "line": 315,
            "function": "is_unique",
            "class": "CodeIgniter\\Validation\\Rules",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Validation\\Validation.php",
            "line": 175,
            "function": "processRules",
            "class": "CodeIgniter\\Validation\\Validation",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Controller.php",
            "line": 140,
            "function": "run",
            "class": "CodeIgniter\\Validation\\Validation",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\app\\Controllers\\Api\\Auth.php",
            "line": 53,
            "function": "validate",
            "class": "CodeIgniter\\Controller",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
            "line": 902,
            "function": "register",
            "class": "App\\Controllers\\Api\\Auth",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
            "line": 457,
            "function": "runController",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\CodeIgniter.php",
            "line": 340,
            "function": "handleRequest",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\public\\index.php",
            "line": 67,
            "function": "run",
            "class": "CodeIgniter\\CodeIgniter",
            "type": "->"
        },
        {
            "file": "C:\\Applications\\projects\\php\\project-api\\vendor\\codeigniter4\\framework\\system\\Commands\\Server\\rewrite.php",
            "line": 46,
            "args": [
                "C:\\Applications\\projects\\php\\project-api\\public\\index.php"
            ],
            "function": "require_once"
        }
    ]
}



RE: Database Exception showing TRACE even in PROD - kenjis - 10-13-2022

Cannot reproduce.

If CI_ENVIRONMENT = production, I get no output from curl.

Do you see Whoops! page when you get the URL from your browser?


RE: Database Exception showing TRACE even in PROD - encodedigital - 10-17-2022

It is working fine now. Something must been wrong with my env at that time. I restarted and now it is showing trace only when it is in development. Apologies guys for false alarm.