Skip to content

Include the file + line number in the Lambda failure logs #1619

@driskell

Description

@driskell

Description:

When a lambda invoke error occurs, you get an error like follows in CloudWatch:

7a3b55ac-f1df-417f-9414-230fda2acb1f	Invoke Error	
{
    "errorType": "ErrorException",
    "errorMessage": "Warning: Trying to access array offset on value of type null",
    "stack": [
        "#0 /var/task/custom_code(24): CustomCode->handle(Array)",
        "#1 /var/task/vendor/bref/bref/src/Runtime/Invoker.php(29): Bref\\Runtime\\FileHandlerLocator::{closure}(Array, Object(Bref\\Context\\Context))",
        "#2 /var/task/vendor/bref/bref/src/Runtime/LambdaRuntime.php(89): Bref\\Runtime\\Invoker->invoke(Object(Closure), Array, Object(Bref\\Context\\Context))",
        "#3 /var/task/vendor/bref/bref/src/FunctionRuntime/Main.php(37): Bref\\Runtime\\LambdaRuntime->processNextEvent(Object(Closure))",
        "#4 /opt/bref/bootstrap.php(17): Bref\\FunctionRuntime\\Main::run()",
        "#5 {main}"
    ]
}

However, the stack is only showing the stack - not the current context of the error. In this case we called CustomCode->handle but there is no notification of the file that is in, nor the line number the error occurred on. Some errors raised by PHP contain this information where in the message it says (on line X in Y) but some errors do not (not entirely sure why to be honest!).

How to reproduce:

PHP 8.0
Access array offset on null and see if the line number appears

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions