Skip to content

fix: remove trailing comma in device edit SNMP settings UPDATE - #397

Merged
TheWitness merged 2 commits into
developfrom
fix/device-edit-snmp-update-sql
Oct 16, 2026
Merged

TheWitness merged 2 commits into
developfrom
fix/device-edit-snmp-update-sql

Conversation

@TheWitness

Copy link
Copy Markdown
Member

Fixes a SQL syntax error in the device edit page.

The UPDATE mac_track_devices that persists auto-corrected SNMP settings ended its SET list with snmp_context = ?, immediately before WHERE, which MariaDB/MySQL reject. Seen in the Cacti log as SQL Backtrace: mactrack_devices.php[54]:mactrack_device_edit() -> db_execute_prepared().

Changes:

  • Remove the trailing comma
  • CHANGELOG entry
  • Regression test that no UPDATE has a comma before WHERE

Note: the related Undefined array key warnings in build_InterfacesTable() (v4.8, mactrack_functions.php:743) are already guarded by isset() on develop.

The UPDATE mac_track_devices statement ended its SET list with a comma
before WHERE, causing an SQL syntax error whenever the device edit page
auto-corrected the SNMP settings. Adds a regression test.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 16, 2026 16:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The narrow correction resolves the SQL error, and the regression assertions detect the original defect.

0 open findings

What changed in this PR

Fixes the SQL syntax error when the device edit page saves auto-corrected SNMP settings.

Changes:

  • Removes the trailing comma before WHERE.
  • Adds a regression test and changelog entry.
File Description
tests/​Unit/​DeviceEditSnmpUpdateSqlTest.php Checks for trailing commas before WHERE.
mactrack_devices.php Corrects the SNMP settings UPDATE syntax.
CHANGELOG.md Documents the fix.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

xmacan
xmacan previously approved these changes Oct 16, 2026
@TheWitness
TheWitness merged commit 73b5297 into develop Oct 16, 2026
5 checks passed
@TheWitness
TheWitness deleted the fix/device-edit-snmp-update-sql branch October 20, 2026 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants