Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/autoconf/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def exit_handler(signum, frame):
Path(sep, "var", "tmp", "bunkerweb", "autoconf.healthy").write_text("ok")
LOGGER.info("Processing events ...")
controller.process_events()
except:
except Exception:
LOGGER.error(f"Exception while running autoconf :\n{format_exc()}")
sys_exit(1)
finally:
Expand Down
2 changes: 1 addition & 1 deletion src/common/gen/save_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@
LOGGER.error(f"An error occurred when setting the changes to checked in the database : {ret}")
except SystemExit as e:
sys_exit(e.code)
except:
except Exception:
LOGGER.error(f"Exception while executing config saver : {format_exc()}")
sys_exit(1)

Expand Down
4 changes: 2 additions & 2 deletions src/common/utils/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def cache_file(

if ret and isinstance(file_cache, Path) and delete_file and file_cache != cache_path:
file_cache.unlink(missing_ok=True)
except:
except Exception:
return False, f"exception :\n{format_exc()}"
Comment on lines +263 to 264
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# First, locate and examine the target file
wc -l src/common/utils/jobs.py

Repository: bunkerity/bunkerweb

Length of output: 91


🏁 Script executed:

# Get the full context around lines 263-264 and 299-300
sed -n '250,280p' src/common/utils/jobs.py

Repository: bunkerity/bunkerweb

Length of output: 1383


🏁 Script executed:

# Also check lines around 299-300
sed -n '285,310p' src/common/utils/jobs.py

Repository: bunkerity/bunkerweb

Length of output: 1067


🏁 Script executed:

# Find all callers of cache_file and del_cache methods
rg 'cache_file|del_cache' --type py -B 2 -A 2

Repository: bunkerity/bunkerweb

Length of output: 50375


🏁 Script executed:

sed -n '235,275p' src/common/utils/jobs.py

Repository: bunkerity/bunkerweb

Length of output: 1706


🏁 Script executed:

sed -n '280,310p' src/common/utils/jobs.py

Repository: bunkerity/bunkerweb

Length of output: 1314


Catch specific database exceptions instead of broad Exception in utility methods.

Lines 263–264 (cache_file) and 299–300 (del_cache) catch Exception around database operations. These are helper methods invoked from job scripts (which themselves sit at process boundaries), not process boundaries in their own right. Catching Exception here masks unexpected database failures—connection loss, constraint violations, permission errors—behind a generic (False, "exception") response. Replace with specific exception types (e.g. SQLAlchemy exceptions or whatever upsert_job_cache() and delete_job_cache() actually raise), or let unexpected exceptions propagate to the calling job script where they can be logged with full context at a process boundary.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/common/utils/jobs.py` around lines 263 - 264, The except blocks in
cache_file and del_cache currently catch broad Exception and return a generic
failure; change these to catch the specific database/ORM exceptions that
upsert_job_cache() and delete_job_cache() can raise (e.g., SQLAlchemyError or
the specific error classes used by your DB client) or remove the broad
try/except so errors propagate to the caller; update the handlers to either
catch only those specific exceptions and include the original exception details
in the returned message or allow unexpected exceptions to bubble up to the job
script for proper logging and handling (refer to functions cache_file,
del_cache, upsert_job_cache, delete_job_cache and remove reliance on a blanket
except Exception with format_exc()).

return ret, err

Expand Down Expand Up @@ -296,7 +296,7 @@ def del_cache(self, name: Union[str, Path], *, job_name: str = "", service_id: s

try:
self.db.delete_job_cache(name, job_name=job_name, service_id=service_id) # type: ignore
except:
except Exception:
return False, f"exception :\n{format_exc()}"
return ret, err

Expand Down