Skip to content

fix(common): handle undefined error in sendError - #1743

Merged
ajile-in merged 1 commit into
mainfrom
fix/coderabbit-senderror-undefined
Sep 12, 2026
Merged

ajile-in merged 1 commit into
mainfrom
fix/coderabbit-senderror-undefined

Conversation

@ajile-in

Copy link
Copy Markdown
Member

What changed

Addresses CodeRabbit feedback on #1742.

sendError() takes any and httpPut() passes its caught rejection straight through, so sendError(undefined) was reachable. It crashed with a TypeError because:

  1. The logger evaluated error.response?.status before any guard
  2. The if condition dereferenced error.response directly
  3. The 500 fallback read error.message directly

Fix

  • libs/common/src/common.service.ts: guard all three dereferences with optional chaining (error?.response?.status, error?.response?.data, error?.message). Behavior for defined errors is unchanged.

Test

  • Added falls back to 500 when passed undefined to common.service.spec.ts covering service.sendError(undefined).

Verification

  • common.service.spec.ts + http-client.integration.spec.ts: 28 tests passing
  • CI config (jest.ci.config.js): 18 suites / 234 tests passing
  • ESLint: clean
  • Commit is SSH-signed with DCO Signed-off-by trailer

Guard all error dereferences in sendError so an undefined argument does
not throw a TypeError before the 500 fallback. Add a regression test for
service.sendError(undefined). Addresses CodeRabbit feedback on #1742.

Signed-off-by: Ajay Jadhav <ajay@ayanworks.com>
@coderabbitai

coderabbitai Bot commented Sep 12, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 27 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: d807866b-59f0-4d24-b505-a911ac3ad570

📥 Commits

Reviewing files that changed from the base of the PR and between 340285e and 6d9fa4d.

📒 Files selected for processing (2)
  • libs/common/src/common.service.spec.ts
  • libs/common/src/common.service.ts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@sonarqubecloud

Copy link
Copy Markdown

@ajile-in ajile-in assigned ajile-in and unassigned ajile-in Sep 12, 2026
@ajile-in
ajile-in merged commit b9ba577 into main Sep 12, 2026
9 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.

1 participant