Skip to content
Merged
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
23 changes: 6 additions & 17 deletions dcs_core/integrations/databases/sybase.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,9 @@ def connect(self) -> Any:
conn_dict["host"] = host or server

try:
logger.debug(f"Attempting FreeTDS connection with config: {conn_dict}")
logger.debug("Attempting FreeTDS connection")
self.connection = pyodbc.connect(**conn_dict)
logger.info(
f"Successfully connected to Sybase using FreeTDS: {conn_dict}"
)
logger.info("Successfully connected to Sybase using FreeTDS")
return self.connection
except Exception as e:
error_msg = f"Failed to connect to Sybase with FreeTDS: {str(e)}"
Expand Down Expand Up @@ -149,24 +147,15 @@ def connect(self) -> Any:
final_config.update(ase_config)

try:
logger.debug(
f"Attempting connection with config: {final_config}"
)
logger.debug("Attempting connection ...")
self.connection = pyodbc.connect(**final_config)
logger.info(
f"Successfully connected to Sybase using: "
f"driver={driver}, "
f"{attempt['key']}={attempt['value']}, "
f"port_config={port_config}, "
f"ase_config={ase_config}"
"Successfully connected to Sybase using: "
f"driver={driver}"
)
return self.connection
except Exception as e:
error_msg = (
f"Failed with {attempt['key']}={attempt['value']}, "
f"port_config={port_config}, "
f"ase_config={ase_config}: {str(e)}"
)
error_msg = "Failed to connect to sybase."
logger.debug(error_msg)
errors.append(error_msg)
continue
Comment on lines 157 to 161
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix unused exception variable (Ruff F841) and improve failure diagnostics.

Currently e is unused and every attempt appends the same generic error, reducing debuggability. Include a sanitized summary (exception class + first line) to both logs and aggregation; this also resolves F841.

-                    except Exception as e:
-                        error_msg = "Failed to connect to sybase."
-                        logger.debug(error_msg)
-                        errors.append(error_msg)
-                        continue
+                    except Exception as e:
+                        # Include exception class and first line only; avoids leaking connection params
+                        err_summary = f"{type(e).__name__}: {str(e).splitlines()[0]}"
+                        logger.debug(f"Connection attempt failed: {err_summary}")
+                        errors.append(err_summary)
+                        continue
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
except Exception as e:
error_msg = (
f"Failed with {attempt['key']}={attempt['value']}, "
f"port_config={port_config}, "
f"ase_config={ase_config}: {str(e)}"
)
error_msg = "Failed to connect to sybase."
logger.debug(error_msg)
errors.append(error_msg)
continue
except Exception as e:
# Include exception class and first line only; avoids leaking connection params
err_summary = f"{type(e).__name__}: {str(e).splitlines()[0]}"
logger.debug(f"Connection attempt failed: {err_summary}")
errors.append(err_summary)
continue
🧰 Tools
🪛 Ruff (0.12.2)

157-157: Local variable e is assigned to but never used

Remove assignment to unused variable e

(F841)

🤖 Prompt for AI Agents
In dcs_core/integrations/databases/sybase.py around lines 157 to 161, the except
block currently binds an unused variable `e` and appends a generic error
message; change it to use `e` by building a sanitized summary (exception class
name + first line of str(e)) and include that summary in the logger call and in
the errors list (e.g., combine a short contextual message with the summary).
This removes the unused-variable warning and provides better diagnostics while
preserving the loop continue behavior.

Expand Down
Loading