Skip to content

fix(rdb): null-guard view/function/procedure list endpoints - #2404

Merged
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/list-endpoints-nullsafe-2403
Aug 3, 2026
Merged

fix(rdb): null-guard view/function/procedure list endpoints#2404
openai0229 merged 3 commits into
OtterMind:mainfrom
Aias00:fix/list-endpoints-nullsafe-2403

Conversation

@Aias00

@Aias00 Aias00 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

What

DbFunctionController, DbProcedureController, and DbViewController list endpoints called .size() directly on the service/converter result, NPEing when it returned null (some JDBC drivers return null for empty result sets). DbTriggerController already guards with CollectionUtils.isNotEmpty.

Location

  • DbViewController.java:53-57
  • DbFunctionController.java:38-42
  • DbProcedureController.java:38-42
  • DbTriggerController.java:39-43 (reference, already guarded)

Fix

Align the three unguarded controllers with a null-safe size computation (compute size only when non-null). Mirrors DbTriggerController's intent without adding an import. Real DB-level pagination is a separate feature.

Verification

  • Long.valueOf(size) where size is an int; 1/size autobox to Integer for of(List, Long, Integer, Integer).
  • No NPE when the service/converter returns null.

Refs #2403

🤖 Generated with Claude Code

…d#2403)

DbFunctionController/DbProcedureController/DbViewController list endpoints
called .size() directly on the service/converter result, NPEing when it
returned null (some JDBC drivers return null for empty result sets).
DbTriggerController already guarded with CollectionUtils.isNotEmpty. Align
the three with a null-safe size computation.

Co-Authored-By: Claude <noreply@anthropic.com>
Signed-off-by: liuhy <liuhongyu@apache.org>
Copilot AI review requested due to automatic review settings August 3, 2026 06:48
@Aias00
Aias00 requested a review from openai0229 as a code owner August 3, 2026 06:48

Copilot AI 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.

Pull request overview

This PR fixes a null-handling bug in the RDB metadata “list” endpoints for views, functions, and procedures. Previously, these controllers called .size() on potentially null lists (some JDBC drivers can return null instead of an empty list), causing NPEs; the change aligns their behavior with the already-null-safe trigger endpoint pattern.

Changes:

  • Add null-safe size computation in DbViewController.list, DbFunctionController.list, and DbProcedureController.list.
  • Preserve existing “fake pagination” behavior while ensuring WebPageResult.of(...) is constructed without dereferencing a null list.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
chat2db-community-server/chat2db-community-web/src/main/java/ai/chat2db/community/web/api/controller/DbViewController.java Null-guards the converted view list before computing size/total for WebPageResult.
chat2db-community-server/chat2db-community-web/src/main/java/ai/chat2db/community/web/api/controller/DbProcedureController.java Null-guards procedure list before computing size/total for WebPageResult.
chat2db-community-server/chat2db-community-web/src/main/java/ai/chat2db/community/web/api/controller/DbFunctionController.java Null-guards function list before computing size/total for WebPageResult.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@openai0229 openai0229 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.

Reviewed the null normalization across the three metadata list endpoints after syncing with the latest main. The Web module packages successfully. This PR only addresses the null-result NPE; the description now uses Refs #2403 so the still-open result-cap/pagination work is not closed incorrectly.

@openai0229
openai0229 merged commit 4fad37a into OtterMind:main Aug 3, 2026
16 of 17 checks passed
@openai0229 openai0229 moved this from In Review to Done in Chat2DB Community Aug 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants