From 9b6e9332253cf74082c3a1a72eafba7957375d3b Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Fri, 16 Oct 2026 22:21:04 -1000 Subject: Name every Lua filter failure in the log A script raising anything but a string handed die a null to print, and a Lua state that could not be created was used anyway once the filter closed. --- tests/t0201-filters.sh | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tests') diff --git a/tests/t0201-filters.sh b/tests/t0201-filters.sh index c2d0ec4..1ffb973 100755 --- a/tests/t0201-filters.sh +++ b/tests/t0201-filters.sh @@ -130,6 +130,19 @@ test_expect_success CGIT_LUA 'a failing lua filter still renders an error page' grep "Lua error in" err ' +# A script may raise a value that is no string, which the log still names. +test_expect_success CGIT_LUA 'a lua filter raising a table is named by type' ' + cat >tabled.lua <<-\EOF && + function filter_open(...) error({}) end + function filter_write(str) end + function filter_close() return 0 end + EOF + sed "s|broken.lua|tabled.lua|" brokenrc >tabledrc && + CGIT_CONFIG="$PWD/tabledrc" QUERY_STRING="url=foo/commit" cgit >tmp 2>err && + grep "Status: 500" tmp && + grep "Lua error in .*tabled.lua: (error object is a table value)" err +' + # A script runs its top level before cgit hooks stdout for it, so what it # writes there goes straight onto the page instead of tripping the hook. test_expect_success CGIT_LUA 'a lua filter that writes while loading still renders' ' -- cgit