Repository navigation
Conversation
Implement conversation messages retrieval via ServiceNow integration:
- domain: ConversationMessage, GetConversationMessagesRequest/Response types
- service: ConversationService interface; snConversationService calls
POST /comments/search with referenceType=conversation on the Choreo API
- handler: ConversationHandler reads limit/offset from query params
- routes: register GET /conversations/{id}/messages (SN data source only)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Wire the new entity-service conversation messages endpoint into the CSM
portal BFF:
- entity client: GetConversationMessages forwards conversationID + raw
query string to GET /conversations/{id}/messages on the entity service
- handler: ConversationHandler validates UUID path param, passes query
string through, maps upstream errors
- route: GET /conversations/{id}/messages registered in main.go
- openapi.yaml: document path with ConversationMessage schema
- README: add Conversations section
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Warning Review limit reached
Next review available in: 31 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughAdds a new ChangesConversation Messages Feature
Estimated code review effort: 3 (Moderate) | ~25 minutes Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
entity-service/internal/service/sn_conversation_service.go (1)
50-54: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMisleading shared-type name:
snProjectPaginationused for comments search.The pagination struct name suggests it's project-specific, but it's reused here for the
/comments/searchpayload. If this type is genuinely a shared, generic pagination shape, consider renaming it to something scope-neutral (e.g.snPagination) to avoid confusion at call sites like this one.🤖 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 `@entity-service/internal/service/sn_conversation_service.go` around lines 50 - 54, The pagination type name is misleading because snProjectPagination is being used for comments search in snConversationService; rename this shared pagination shape to a scope-neutral name like snPagination and update the snSearchCommentsPayload construction and any other call sites or references so the type reflects its generic use.
🤖 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 `@entity-service/internal/handler/conversation_handler.go`:
- Around line 42-47: GetConversationMessages currently forwards
r.PathValue("id") directly into domain.GetConversationMessagesRequest without
validating it, so malformed IDs can reach ServiceNow. Update
ConversationHandler.GetConversationMessages to validate the conversation ID
first using the existing uuidToSysid path or equivalent UUID/canonical ID check,
and return a 400 Bad Request when the value is invalid instead of calling the
downstream service.
In `@entity-service/internal/service/sn_conversation_service.go`:
- Around line 67-71: The loop in sn_conversation_service.go currently aborts
GetConversationMessagesResponse construction when a single snResp.Comments item
has an invalid CreatedOn value. Update the parsing path inside the comments
iteration to log the malformed record and continue processing the remaining
comments, or apply a safe default for createdAt, so one bad ServiceNow timestamp
does not fail the whole response. Keep the change localized to the
comment-processing logic that calls time.Parse and returns the response.
---
Nitpick comments:
In `@entity-service/internal/service/sn_conversation_service.go`:
- Around line 50-54: The pagination type name is misleading because
snProjectPagination is being used for comments search in snConversationService;
rename this shared pagination shape to a scope-neutral name like snPagination
and update the snSearchCommentsPayload construction and any other call sites or
references so the type reflects its generic use.
🪄 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: CHILL
Plan: Pro
Run ID: fa83536e-b71b-4a0d-bd7e-b35eeb6cdb51
📒 Files selected for processing (12)
apps/csm-portal/backend/README.mdapps/csm-portal/backend/cmd/server/main.goapps/csm-portal/backend/internal/entity/entity.goapps/csm-portal/backend/internal/handler/conversations.goapps/csm-portal/backend/internal/handler/conversations_test.goapps/csm-portal/backend/internal/handler/helpers_test.goapps/csm-portal/backend/openapi.yamlentity-service/internal/domain/entity.goentity-service/internal/handler/conversation_handler.goentity-service/internal/server/routes.goentity-service/internal/service/interfaces.goentity-service/internal/service/sn_conversation_service.go
Replace the conversation-specific GET endpoint design with a generic POST /comments/search endpoint on the entity-service, mirroring the Ballerina entity-service pattern: Entity-service: - domain: add Comment, SearchCommentsRequest, SearchCommentsResponse types (replacing the removed ConversationMessage types) - service: add CommentService interface; snCommentSearchService calls POST /comments/search on the Choreo API with referenceType forwarded - handler: CommentHandler.SearchComments decodes the request and delegates to the service - routes: register POST /comments/search (SN data source only) - openapi.yaml: document POST /comments/search with Comment schema CSM portal BFF: - entity client: SearchComments calls POST /comments/search - handler: GetConversationMessages builds the referenceType=conversation payload, validates limit/offset query params, and calls SearchComments Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ce for SN
For the ServiceNow data source, POST /cases/{id}/comments/search now delegates
to the generic CommentService.SearchComments (with referenceType=case injected
from the path), eliminating the duplicate Choreo integration in snCaseService.
The postgres path is unchanged. CSM portal backend similarly injects referenceId
and referenceType and calls POST /comments/search on the entity service directly.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…onse A single malformed timestamp from ServiceNow no longer fails the whole page; the offending record is logged at WARN and skipped. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Callers (CSM portal cases and conversations endpoints) now call the generic POST /comments/search directly with the appropriate referenceId and referenceType, so the case-specific route is no longer needed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Summary
GET /conversations/{id}/messagesbacked by ServiceNow. The service callsPOST /comments/searchon the Choreo integration API withreferenceType=conversation, mapssnCommentresponses toConversationMessagedomain types (with sysid ↔ UUID conversion), and returns a paginated result. Optionallimitandoffsetquery parameters are parsed and validated in the handler layer.GET /conversations/{id}/messagesthat validates the UUID path param and forwards the raw query string directly to the entity service. The entity client appends the query string to the path. Route registered inmain.go, documented inopenapi.yamlandREADME.md.Test plan
go test ./...passes in bothentity-service/andapps/csm-portal/backend/TestGetConversationMessagescovers: unauthenticated, empty ID, non-UUID ID, query forwarding, 200 response shape, and full upstream error tableGET /conversations/{id}/messages?limit=10&offset=0returns messages from the SN integration service for a valid conversation ID🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
limitandoffsetpaging, with clearer response data including totals and “has more” state.Bug Fixes