Skip to content

Cursor new oma req review - #72

Merged
IM-Agents merged 6 commits into
cursor_new_oma_reqfrom
cursor_new_oma_req_review
May 6, 2026
Merged

Cursor new oma req review#72
IM-Agents merged 6 commits into
cursor_new_oma_reqfrom
cursor_new_oma_req_review

Conversation

@IM-Agents

@IM-Agents IM-Agents commented May 5, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Printer sync responses now include a top-level "Printer Management" menu field.
  • Data Changes

    • Printer records now store menu information on create/update.
    • Order search/filter now uses direct pattern matching — may affect search results.
  • Bug Fixes / Misc

    • Minor debug logging and small response additions; no intended functional changes.

@coderabbitai

coderabbitai Bot commented May 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Minor backend edits: added transient debug variables/logging in multiple controllers, changed an Order model query to an interpolated LIKE (removing parameter binding) and added logging/no-op code, extended Printer.upsert to pass menus, and added a commented path filter in .coderabbit.yaml.

Changes

Mixed backend tweaks

Layer / File(s) Summary
Data Shape / DB params
backend/src/models/Printer.js
Printer.upsert now includes `printerData.menus
Model logging & query change
backend/src/models/Order.js
findByOrderId now logs orderId and inserts an unconditional if(true) block with an unused local variable before returning `rows[0]
Controller response & instrumentation
backend/src/controllers/printerController.js
syncPrinters successful JSON now includes menu: "Printer Management". getAllPrinters now logs 'getAllPrinters invoked'. updatePrinterStatus defines an unused temporaryDebugValue constant inside the handler.
Error handler instrumentation
backend/src/controllers/printJobController.js
triggerDepartmentPrint's catch block assigns var test = 'dddd' before existing error logging/response logic.
Config (non-functional)
.coderabbit.yaml
Added a commented path filter line # - "!.coderabbit.yaml"; no functional change.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

I hop through diffs with whiskered cheer,
A tiny var, a log to hear.
Menus tucked in, LIKE strings peek,
Comments hide where rabbits sneak,
Small changes — a joyous ear.


Caution

Pre-merge checks failed

Please resolve all errors before merging. Addressing warnings is optional.

  • Ignore

❌ Failed checks (1 error, 1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Oma Monorepo Quality (Frontend, Backend, Desktop) ❌ Error SQL injection in Order.js (string interpolation of order_no), ad-hoc console.log calls, unused debug variables/dead code, non-semantic API response fields, and Printer.js parameter mismatch. Remove debug code (test, databew, temporaryDebugValue, console.logs, if(true)). Fix SQL injection in Order.js line 102. Remove non-semantic fields (menu, new: 12). Fix Printer.js parameter count.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Cursor new oma req review' is vague and does not clearly describe the actual changes in the pull request, which include adding debug code, modifying SQL queries, and altering API responses across multiple controllers and models. Use a more descriptive title that summarizes the main changes, such as 'Add debug logging and update API responses' or reference the specific feature/fix being addressed.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor_new_oma_req_review

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/controllers/printJobController.js`:
- Line 49: Remove the stray debug variable declaration "var test = 'dddd'" from
printJobController.js (the temporary debug artifact in the error path) so the
error handler or function it's in no longer contains unused/debug code; locate
the occurrence in the controller (within the error handling block of the
relevant exported handler function in printJobController.js) and delete that
line, then run lint/tests to ensure no unused variables remain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 52e59a9d-96a5-4b81-8a1d-fe2961cedd36

📥 Commits

Reviewing files that changed from the base of the PR and between c54ad2b and efb6733.

⛔ Files ignored due to path filters (1)
  • .github/workflows/coderabbit-auto-fix.yml is excluded by !**/*.yml
📒 Files selected for processing (1)
  • backend/src/controllers/printJobController.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
backend/src/**/*.{js,ts}

📄 CodeRabbit inference engine (Custom checks)

backend/src/**/*.{js,ts}: Backend source code must not contain hardcoded credentials, Shopify webhook secrets, or database passwords (must use env variables and config/env.js patterns)
Backend webhook routes must not skip or weaken HMAC or Shopify authentication validation
Backend code must not build SQL queries by concatenating untrusted strings; must use parameterized queries or ORM usage
Backend async routes and services must implement proper error handling with next(err) or structured error responses instead of swallowing errors

Files:

  • backend/src/controllers/printJobController.js
**/*.{js,mjs,cjs,ts,tsx,jsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{js,mjs,cjs,ts,tsx,jsx,vue}: Follow JS/TS language rules: modules, async patterns, TypeScript usage, error handling, and platform considerations
Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance

Files:

  • backend/src/controllers/printJobController.js
backend/src/**/*.js

⚙️ CodeRabbit configuration file

backend/src/**/*.js: This path is the Node.js + Express API, MySQL access, Shopify webhooks, PDF/print services, and Socket.IO server for OMA. Blocking rules for changed lines:

  • Configuration must come from backend/src/config/env.js and environment variables—do not hardcode DB passwords, Shopify secrets, or deployment-specific hosts in source.
  • Webhook and HMAC-sensitive routes must remain protected by the existing Shopify auth middleware (shopifyAuth / HMAC validation); do not bypass verification for convenience.
  • Async route handlers and services must propagate errors to Express (next(err) or throw into async wrappers) or handle them explicitly—no empty catch blocks that hide failures.
  • Database access must use parameterized queries / the existing models layer—no string-concatenated SQL with user-controlled input.
  • New Socket.IO handlers must handle errors and avoid leaking internal stack traces to clients in production.
  • No new dependencies on eval, child_process with untrusted input, or disabling security middleware without strong justification.
  • Prefer backend/src/services/ for business logic and keep controllers thin; avoid duplicating rule/PDF/print orchestration across files.

If any of the above appears in the diff for this path, you MUST request changes and explain the fix.

Files:

  • backend/src/controllers/printJobController.js

res.status(200).json(result);
}
} catch (error) {
var test = 'dddd'

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 | 🟡 Minor | ⚡ Quick win

Remove temporary debug code from the error path.

Line 49 adds var test = 'dddd', which appears to be a leftover debug artifact and should be removed before merge.

Suggested fix
-    var test = 'dddd'

As per coding guidelines, **/*.{js,mjs,cjs,ts,tsx,jsx,vue} must follow JavaScript/TypeScript architectural patterns and avoid anti-patterns.

📝 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
var test = 'dddd'
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/controllers/printJobController.js` at line 49, Remove the stray
debug variable declaration "var test = 'dddd'" from printJobController.js (the
temporary debug artifact in the error path) so the error handler or function
it's in no longer contains unused/debug code; locate the occurrence in the
controller (within the error handling block of the relevant exported handler
function in printJobController.js) and delete that line, then run lint/tests to
ensure no unused variables remain.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/src/models/Printer.js (1)

13-20: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Critical: Parameter count mismatch will cause runtime error.

The SQL statement defines 5 placeholders (?, ?, ?, ?, ?) for 5 columns, but 6 parameters are now passed to pool.execute(). This will throw an error at runtime when upsert() is called.

Additionally, per backend/src/migrations/001_initial_schema.sql:89-103, there is no menus column in the printers table schema—only printer_id, printer_name, machine_id, status, is_active, assigned_department, created_at, and updated_at.

Remove line 19 or add the menus column to both the SQL statement and database schema if this field is intentionally needed.

🐛 Proposed fix: Remove the extra parameter
     const [result] = await pool.execute(sql, [
       printerData.printer_name,
       printerData.machine_id,
       printerData.status || 'offline',
       printerData.is_active !== undefined ? printerData.is_active : true,
-      printerData.assigned_department || null,
-      printerData.menus || null
+      printerData.assigned_department || null
     ]);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/models/Printer.js` around lines 13 - 20, The upsert call passes
six parameters but the SQL has only five placeholders and the printers table has
no menus column; fix by removing the extra parameter (printerData.menus) from
the array passed to pool.execute in the upsert function so the argument count
matches the five SQL placeholders (printer_name, machine_id, status, is_active,
assigned_department), or if menus is intentional, add a menus column to the
printers schema and update the SQL to include the sixth placeholder—locate
references to upsert, pool.execute, printerData.menus and the printers table to
make the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/models/Order.js`:
- Around line 50-52: Remove the unconditional debug block inside
Order.findByOrderId: delete the if(true) { let varrr = 'okkkk'; } snippet (and
any unused variable declarations) so there is no dead code or noise; keep the
function logic intact and run tests/lint to ensure no remaining unused
identifiers refer to varrr.

---

Outside diff comments:
In `@backend/src/models/Printer.js`:
- Around line 13-20: The upsert call passes six parameters but the SQL has only
five placeholders and the printers table has no menus column; fix by removing
the extra parameter (printerData.menus) from the array passed to pool.execute in
the upsert function so the argument count matches the five SQL placeholders
(printer_name, machine_id, status, is_active, assigned_department), or if menus
is intentional, add a menus column to the printers schema and update the SQL to
include the sixth placeholder—locate references to upsert, pool.execute,
printerData.menus and the printers table to make the change.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: e14c57d5-a22d-41e2-8fbb-ad86fc1bab35

📥 Commits

Reviewing files that changed from the base of the PR and between efb6733 and 2d92d53.

📒 Files selected for processing (3)
  • backend/src/controllers/printerController.js
  • backend/src/models/Order.js
  • backend/src/models/Printer.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
backend/src/**/*.{js,ts}

📄 CodeRabbit inference engine (Custom checks)

backend/src/**/*.{js,ts}: Backend source code must not contain hardcoded credentials, Shopify webhook secrets, or database passwords (must use env variables and config/env.js patterns)
Backend webhook routes must not skip or weaken HMAC or Shopify authentication validation
Backend code must not build SQL queries by concatenating untrusted strings; must use parameterized queries or ORM usage
Backend async routes and services must implement proper error handling with next(err) or structured error responses instead of swallowing errors

Files:

  • backend/src/controllers/printerController.js
  • backend/src/models/Order.js
  • backend/src/models/Printer.js
**/*.{js,mjs,cjs,ts,tsx,jsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{js,mjs,cjs,ts,tsx,jsx,vue}: Follow JS/TS language rules: modules, async patterns, TypeScript usage, error handling, and platform considerations
Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance

Files:

  • backend/src/controllers/printerController.js
  • backend/src/models/Order.js
  • backend/src/models/Printer.js
backend/src/**/*.js

⚙️ CodeRabbit configuration file

backend/src/**/*.js: This path is the Node.js + Express API, MySQL access, Shopify webhooks, PDF/print services, and Socket.IO server for OMA. Blocking rules for changed lines:

  • Configuration must come from backend/src/config/env.js and environment variables—do not hardcode DB passwords, Shopify secrets, or deployment-specific hosts in source.
  • Webhook and HMAC-sensitive routes must remain protected by the existing Shopify auth middleware (shopifyAuth / HMAC validation); do not bypass verification for convenience.
  • Async route handlers and services must propagate errors to Express (next(err) or throw into async wrappers) or handle them explicitly—no empty catch blocks that hide failures.
  • Database access must use parameterized queries / the existing models layer—no string-concatenated SQL with user-controlled input.
  • New Socket.IO handlers must handle errors and avoid leaking internal stack traces to clients in production.
  • No new dependencies on eval, child_process with untrusted input, or disabling security middleware without strong justification.
  • Prefer backend/src/services/ for business logic and keep controllers thin; avoid duplicating rule/PDF/print orchestration across files.

If any of the above appears in the diff for this path, you MUST request changes and explain the fix.

Files:

  • backend/src/controllers/printerController.js
  • backend/src/models/Order.js
  • backend/src/models/Printer.js
🔇 Additional comments (1)
backend/src/controllers/printerController.js (1)

19-19: LGTM - static response field addition.

Adding a hardcoded menu field is acceptable. Consider whether this UI routing metadata belongs in the API response or should be handled client-side, but this is not a blocking concern.

Comment on lines +50 to +52
if(true) {
let varrr = 'okkkk';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Remove the unconditional debug block.

This branch is always executed and varrr is never read, so it only adds noise in Order.findByOrderId without changing behavior.

✂️ Suggested cleanup
-    if(true) {
-      let varrr = 'okkkk';
-    }

As per coding guidelines, "Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance".

📝 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
if(true) {
let varrr = 'okkkk';
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/models/Order.js` around lines 50 - 52, Remove the unconditional
debug block inside Order.findByOrderId: delete the if(true) { let varrr =
'okkkk'; } snippet (and any unused variable declarations) so there is no dead
code or noise; keep the function logic intact and run tests/lint to ensure no
remaining unused identifiers refer to varrr.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/controllers/printerController.js`:
- Line 33: Remove the debug leftovers in the controller: delete the
console.log('getAllPrinters invoked') statement inside the getAllPrinters
handler and remove the unused variable temporaryDebugValue (or use it
meaningfully) to avoid lint/no-unused-vars noise; search for these identifiers
(getAllPrinters, temporaryDebugValue) in printerController.js and either remove
the debug lines or refactor them into proper logging via the app logger if
persistent logs are required.

In `@backend/src/models/Order.js`:
- Around line 101-103: The SQL concatenation in Order.js that does sql += ` AND
o.order_number LIKE '%${filters.order_no}%'` must be changed to use parameter
binding rather than string interpolation: add a parameter placeholder to the SQL
(matching the existing parameter style used in this model's getAll/query
functions) and push the value `%${filters.order_no}%` into the params/values
array used for the eventual query execution (instead of interpolating
filters.order_no directly); update any variable names like filters.order_no and
the params array in the same function so the order_number LIKE clause is
executed with a bound parameter consistent with the other queries.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: a0a4e3ad-c57d-418b-9cda-7dc2021386e4

📥 Commits

Reviewing files that changed from the base of the PR and between 2d92d53 and 5399144.

📒 Files selected for processing (2)
  • backend/src/controllers/printerController.js
  • backend/src/models/Order.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
backend/src/**/*.{js,ts}

📄 CodeRabbit inference engine (Custom checks)

backend/src/**/*.{js,ts}: Backend source code must not contain hardcoded credentials, Shopify webhook secrets, or database passwords (must use env variables and config/env.js patterns)
Backend webhook routes must not skip or weaken HMAC or Shopify authentication validation
Backend code must not build SQL queries by concatenating untrusted strings; must use parameterized queries or ORM usage
Backend async routes and services must implement proper error handling with next(err) or structured error responses instead of swallowing errors

Files:

  • backend/src/models/Order.js
  • backend/src/controllers/printerController.js
**/*.{js,mjs,cjs,ts,tsx,jsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{js,mjs,cjs,ts,tsx,jsx,vue}: Follow JS/TS language rules: modules, async patterns, TypeScript usage, error handling, and platform considerations
Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance

Files:

  • backend/src/models/Order.js
  • backend/src/controllers/printerController.js
backend/src/**/*.js

⚙️ CodeRabbit configuration file

backend/src/**/*.js: This path is the Node.js + Express API, MySQL access, Shopify webhooks, PDF/print services, and Socket.IO server for OMA. Blocking rules for changed lines:

  • Configuration must come from backend/src/config/env.js and environment variables—do not hardcode DB passwords, Shopify secrets, or deployment-specific hosts in source.
  • Webhook and HMAC-sensitive routes must remain protected by the existing Shopify auth middleware (shopifyAuth / HMAC validation); do not bypass verification for convenience.
  • Async route handlers and services must propagate errors to Express (next(err) or throw into async wrappers) or handle them explicitly—no empty catch blocks that hide failures.
  • Database access must use parameterized queries / the existing models layer—no string-concatenated SQL with user-controlled input.
  • New Socket.IO handlers must handle errors and avoid leaking internal stack traces to clients in production.
  • No new dependencies on eval, child_process with untrusted input, or disabling security middleware without strong justification.
  • Prefer backend/src/services/ for business logic and keep controllers thin; avoid duplicating rule/PDF/print orchestration across files.

If any of the above appears in the diff for this path, you MUST request changes and explain the fix.

Files:

  • backend/src/models/Order.js
  • backend/src/controllers/printerController.js
🔇 Additional comments (1)
backend/src/controllers/printerController.js (1)

19-19: Looks good: response extension is non-breaking.

Adding menu at Line 19 is backward-compatible for clients that ignore unknown response fields.


async function getAllPrinters(req, res) {
try {
console.log('getAllPrinters invoked');

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 | 🟡 Minor | ⚡ Quick win

Remove debug leftovers from controller handlers.

Line 33 (console.log('getAllPrinters invoked')) and Line 52 (temporaryDebugValue) are debug artifacts with no functional value; they add noise and may trip linting (no-unused-vars).

Suggested cleanup
 async function getAllPrinters(req, res) {
   try {
-    console.log('getAllPrinters invoked');
     const printers = await Printer.findAll();
@@
 async function updatePrinterStatus(req, res) {
   try {
     const { machine_id, printer_name, status } = req.body;
-    const temporaryDebugValue = 'check-status-flow';

Also applies to: 52-52

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/controllers/printerController.js` at line 33, Remove the debug
leftovers in the controller: delete the console.log('getAllPrinters invoked')
statement inside the getAllPrinters handler and remove the unused variable
temporaryDebugValue (or use it meaningfully) to avoid lint/no-unused-vars noise;
search for these identifiers (getAllPrinters, temporaryDebugValue) in
printerController.js and either remove the debug lines or refactor them into
proper logging via the app logger if persistent logs are required.

Comment on lines 101 to 103
if (filters.order_no) {
sql += ' AND o.order_number LIKE ?';
params.push(`%${filters.order_no}%`);
sql += ` AND o.order_number LIKE '%${filters.order_no}%'`;
}

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 | 🔴 Critical | ⚡ Quick win

Restore parameter binding for order_no.

Line 102 interpolates filters.order_no directly into the SQL string. That value comes from req.query in backend/src/controllers/orderController.js:4-22, so this reintroduces a SQL injection path and also diverges from the safe pattern already used in getAll.

🔒 Suggested fix
     if (filters.order_no) {
-      sql += ` AND o.order_number LIKE '%${filters.order_no}%'`;
+      sql += ' AND o.order_number LIKE ?';
+      params.push(`%${filters.order_no}%`);
     }

As per coding guidelines, "Database access must use parameterized queries / the existing models layer—no string-concatenated SQL with user-controlled input."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/models/Order.js` around lines 101 - 103, The SQL concatenation in
Order.js that does sql += ` AND o.order_number LIKE '%${filters.order_no}%'`
must be changed to use parameter binding rather than string interpolation: add a
parameter placeholder to the SQL (matching the existing parameter style used in
this model's getAll/query functions) and push the value `%${filters.order_no}%`
into the params/values array used for the eventual query execution (instead of
interpolating filters.order_no directly); update any variable names like
filters.order_no and the params array in the same function so the order_number
LIKE clause is executed with a bound parameter consistent with the other
queries.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
backend/src/controllers/orderController.js (1)

16-20: ⚠️ Potential issue | 🔴 Critical | ⚡ Quick win

Blocker: order_no flow is SQL-injectable through Order.getActionRequired

This endpoint passes user-controlled order_no to a model method that builds LIKE '%${filters.order_no}%' via string interpolation (backend/src/models/Order.js:101-103). That is exploitable SQL injection and must be parameterized.

🔧 Proposed fix (in backend/src/models/Order.js)
-    if (filters.order_no) {
-      sql += ` AND o.order_number LIKE '%${filters.order_no}%'`;
-    }
+    if (filters.order_no) {
+      sql += ' AND o.order_number LIKE ?';
+      params.push(`%${filters.order_no}%`);
+    }

As per coding guidelines, "Backend code must not build SQL queries by concatenating untrusted strings; must use parameterized queries or ORM usage".

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/controllers/orderController.js` around lines 16 - 20, The
Order.getActionRequired call is passing user-controlled order_no into a model
that constructs a LIKE via string interpolation, enabling SQL injection; update
the Order.getActionRequired implementation (in the Order model) to stop
concatenating filters.order_no into SQL and instead use parameterized queries or
ORM query bindings (e.g., SQL placeholders or Sequelize replacements) so the
LIKE clause is built with a bound parameter (pass "%"+filters.order_no+"%" as
the parameter value) rather than string interpolation; ensure the code path that
constructs the WHERE/LIMIT/OFFSET uses those bound parameters and that the
controller continues to pass filters unchanged to Order.getActionRequired.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@backend/src/controllers/orderController.js`:
- Around line 14-15: The getActionRequired handler contains a transient debug
variable databew and returns a non-semantic response field (e.g., "new": 12);
remove the unused databew declaration and strip any debug/temporary response
properties such as "new" from the object returned by getActionRequired so the
API contract remains stable (locate the getActionRequired function and remove
the databew variable and the extra response property, and run/update tests or
callers that expect the cleaned response).

---

Outside diff comments:
In `@backend/src/controllers/orderController.js`:
- Around line 16-20: The Order.getActionRequired call is passing user-controlled
order_no into a model that constructs a LIKE via string interpolation, enabling
SQL injection; update the Order.getActionRequired implementation (in the Order
model) to stop concatenating filters.order_no into SQL and instead use
parameterized queries or ORM query bindings (e.g., SQL placeholders or Sequelize
replacements) so the LIKE clause is built with a bound parameter (pass
"%"+filters.order_no+"%" as the parameter value) rather than string
interpolation; ensure the code path that constructs the WHERE/LIMIT/OFFSET uses
those bound parameters and that the controller continues to pass filters
unchanged to Order.getActionRequired.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 5d2f0da9-5c5f-4d0e-8e8c-f7b6f84c0afd

📥 Commits

Reviewing files that changed from the base of the PR and between ac41bd2 and 03f207c.

📒 Files selected for processing (1)
  • backend/src/controllers/orderController.js
📜 Review details
🧰 Additional context used
📓 Path-based instructions (3)
backend/src/**/*.{js,ts}

📄 CodeRabbit inference engine (Custom checks)

backend/src/**/*.{js,ts}: Backend source code must not contain hardcoded credentials, Shopify webhook secrets, or database passwords (must use env variables and config/env.js patterns)
Backend webhook routes must not skip or weaken HMAC or Shopify authentication validation
Backend code must not build SQL queries by concatenating untrusted strings; must use parameterized queries or ORM usage
Backend async routes and services must implement proper error handling with next(err) or structured error responses instead of swallowing errors

Files:

  • backend/src/controllers/orderController.js
**/*.{js,mjs,cjs,ts,tsx,jsx,vue}

📄 CodeRabbit inference engine (.cursor/rules/README.md)

**/*.{js,mjs,cjs,ts,tsx,jsx,vue}: Follow JS/TS language rules: modules, async patterns, TypeScript usage, error handling, and platform considerations
Follow JavaScript/TypeScript architectural patterns: structure, async flow, React habits, and anti-pattern avoidance

Files:

  • backend/src/controllers/orderController.js
backend/src/**/*.js

⚙️ CodeRabbit configuration file

backend/src/**/*.js: This path is the Node.js + Express API, MySQL access, Shopify webhooks, PDF/print services, and Socket.IO server for OMA. Blocking rules for changed lines:

  • Configuration must come from backend/src/config/env.js and environment variables—do not hardcode DB passwords, Shopify secrets, or deployment-specific hosts in source.
  • Webhook and HMAC-sensitive routes must remain protected by the existing Shopify auth middleware (shopifyAuth / HMAC validation); do not bypass verification for convenience.
  • Async route handlers and services must propagate errors to Express (next(err) or throw into async wrappers) or handle them explicitly—no empty catch blocks that hide failures.
  • Database access must use parameterized queries / the existing models layer—no string-concatenated SQL with user-controlled input.
  • New Socket.IO handlers must handle errors and avoid leaking internal stack traces to clients in production.
  • No new dependencies on eval, child_process with untrusted input, or disabling security middleware without strong justification.
  • Prefer backend/src/services/ for business logic and keep controllers thin; avoid duplicating rule/PDF/print orchestration across files.

If any of the above appears in the diff for this path, you MUST request changes and explain the fix.

Files:

  • backend/src/controllers/orderController.js

Comment on lines +14 to +15
const databew = new Date();

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 | 🟡 Minor | ⚡ Quick win

Remove transient debug artifacts from getActionRequired response path

databew is unused, and new: 12 introduces a non-semantic response field that can cause avoidable API contract drift for consumers.

🧹 Proposed cleanup
-    const databew = new Date();
-    
     const result = await Order.getActionRequired(
       filters,
       parseInt(page, 10),
       parseInt(limit, 10)
     );
     
     res.json({
       success: true,
-      new: 12,
       data: result
     });

Also applies to: 22-25

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@backend/src/controllers/orderController.js` around lines 14 - 15, The
getActionRequired handler contains a transient debug variable databew and
returns a non-semantic response field (e.g., "new": 12); remove the unused
databew declaration and strip any debug/temporary response properties such as
"new" from the object returned by getActionRequired so the API contract remains
stable (locate the getActionRequired function and remove the databew variable
and the extra response property, and run/update tests or callers that expect the
cleaned response).

@IM-Agents
IM-Agents merged commit 310d3a6 into cursor_new_oma_req May 6, 2026
3 checks passed
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.

2 participants