Skip to content

CROSSLINK-209 lms/ncip event logging#391

Merged
adamdickmeiss merged 8 commits intomainfrom
CROSSLINK-209-ncip-event-log
Feb 5, 2026
Merged

CROSSLINK-209 lms/ncip event logging#391
adamdickmeiss merged 8 commits intomainfrom
CROSSLINK-209-ncip-event-log

Conversation

@adamdickmeiss
Copy link
Contributor

@adamdickmeiss adamdickmeiss commented Feb 4, 2026

Copilot AI review requested due to automatic review settings February 4, 2026 16:25
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds LMS/NCIP request/response event logging to patron-request workflows so outbound/inbound messages can be captured in the event stream.

Changes:

  • Introduces a SetLogFunc callback on ncipclient.NcipClient and lms.LmsAdapter to surface raw NCIP XML request/response bytes.
  • Emits new patron-request notice events (lms-requester-message, lms-supplier-message) containing outgoing/incoming LMS payloads.
  • Updates unit tests/mocks and workspace dependency sums accordingly.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
go.work.sum Updates workspace dependency checksum entries.
broker/patron_request/service/message-handler.go Import cleanup (no functional change).
broker/patron_request/service/action.go Hooks LMS adapter logging into patron-request actions and creates notice events with payloads.
broker/patron_request/service/action_test.go Updates mocks to satisfy the expanded LmsAdapter interface.
broker/events/eventmodels.go Adds new event name constants for LMS message notices.
broker/ncipclient/ncipclient.go Adds NcipLogFunc and SetLogFunc to the public client interface.
broker/ncipclient/ncipclient_impl.go Implements log callback plumbing and captures marshaled/unmarshaled XML bytes.
broker/ncipclient/ncipclient_test.go Adds assertions that the log callback is invoked and receives payloads.
broker/lms/lms_adapter.go Extends LMS adapter interface with SetLogFunc.
broker/lms/lms_adapter_ncip.go Forwards logging callback into the underlying NCIP client.
broker/lms/lms_adapter_manual.go Adds no-op SetLogFunc implementation.
broker/lms/lms_adapter_test.go Updates NCIP client mock to satisfy the expanded interface.
Comments suppressed due to low confidence (1)

broker/ncipclient/ncipclient_impl.go:223

  • logFunc currently receives only the HTTP exchange error (err from RequestResponse). If the response contains an NCIP <Problem> (or other post-exchange validation failures), sendReceiveMessage returns an error but the callback still sees err == nil, which will cause downstream event logging to mark these as SUCCESS. Consider determining the final operation error first (including converting <Problem> to an error) and pass that to logFunc so event status reflects real failures.
	err := httpclient.NewClient().RequestResponse(n.client, http.MethodPost, []string{httpclient.ContentTypeApplicationXml},
		n.address, message, &respMessage, marshalFunc, unmarshalFunc)
	if n.logFunc != nil {
		n.logFunc(outgoing, incoming, err)
	}
	if err != nil {
		return nil, fmt.Errorf("NCIP message exchange failed: %s", err.Error())
	}
	if len(respMessage.Problem) > 0 {
		return nil, &NcipError{
			Message: "NCIP message processing failed",
			Problem: respMessage.Problem[0],
		}
	}
	return &respMessage, nil

Comment on lines +138 to +141
var customData = make(map[string]any)
customData["lmsOutgoingMessage"] = string(outgoing)
customData["lmsIncomingMessage"] = string(incoming)
eventData := events.EventData{CustomData: customData}
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

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

Storing full LMS request/response XML bodies in EventData.CustomData can make event.event_data rows very large (responses are allowed up to 10MB by httpclient.DefaultMaxResponseSize). This can bloat the database and slow down event queries. Consider truncating the stored payloads to a reasonable limit, or storing only key fields plus a reference to the full payload elsewhere.

Copilot uses AI. Check for mistakes.
@jakub-id
Copy link
Contributor

jakub-id commented Feb 4, 2026

Looks good minus the Copilot comments

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 13 out of 13 changed files in this pull request and generated 1 comment.

@adamdickmeiss adamdickmeiss merged commit 0f4dfdf into main Feb 5, 2026
4 checks passed
@adamdickmeiss adamdickmeiss deleted the CROSSLINK-209-ncip-event-log branch February 5, 2026 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants