From 67f93e55d8e9be4c81a58920c4651d2eb1327fd6 Mon Sep 17 00:00:00 2001 From: syeopite Date: Sat, 23 Aug 2025 03:35:59 -0700 Subject: [PATCH] Fix "ex" variable collision in invidious.cr The exception handling for database connections results in an `ex` variable which Ameba sees as overshadowing the `ex` used by the `ex` block arg used to define the HTTP status code 500 handler below. Although this is a non-issue since the db connection exception handling will cause Invidious to exit, Ameba's nature as a static checker means that it isn't aware of this. The simplest fix without a dirty ameba ignore comment is to rename `ex` within the Kemal handler block below, since `ex` within a begin rescue block is a Crystal convention that will also cause Ameba to raise when not adhered to. --- src/invidious.cr | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/invidious.cr b/src/invidious.cr index 2d244dd2..197b150c 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -62,8 +62,8 @@ HMAC_KEY = CONFIG.hmac_key PG_DB = begin DB.open CONFIG.database_url -rescue exc - puts "Failed to connect to PostgreSQL database: #{exc.cause.try &.message}" +rescue ex + puts "Failed to connect to PostgreSQL database: #{ex.cause.try &.message}" puts "Check your 'config.yml' database settings or PostgreSQL settings." exit(1) end @@ -227,8 +227,8 @@ error 404 do |env| Invidious::Routes::ErrorRoutes.error_404(env) end -error 500 do |env, ex| - error_template(500, ex) +error 500 do |env, exception| + error_template(500, exception) end static_headers do |env|