Skip to content

lms requestItem returns itemBarcode, callNumber#436

Closed
adamdickmeiss wants to merge 3 commits intomainfrom
supplier-request-item-barcode
Closed

lms requestItem returns itemBarcode, callNumber#436
adamdickmeiss wants to merge 3 commits intomainfrom
supplier-request-item-barcode

Conversation

@adamdickmeiss
Copy link
Contributor

Logging the values. Not storing them yet.

Logging the values. Not storing them yet.
Copilot AI review requested due to automatic review settings March 6, 2026 11:28
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

Updates the LMS RequestItem flow to return additional metadata (item barcode + call number) from NCIP, and surfaces those values in the patron-request lender “will supply” action (currently logged, not persisted).

Changes:

  • Change LmsAdapter.RequestItem to return (itemBarcode, callNumber, error) and update adapter implementations/mocks accordingly.
  • Parse barcode/call number from the NCIP RequestItemResponse and extend unit tests to assert the returned values.
  • Log the RequestItem response values in willSupplyLenderRequest and rename CheckOutItem’s parameter from itemId to itemBarcode in the interface and implementations.

Reviewed changes

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

Show a summary per file
File Description
broker/patron_request/service/action.go Captures RequestItem return values; logs them; adjusts ship flow to use renamed itemBarcode parameter.
broker/patron_request/service/action_test.go Updates failing LMS adapter mock to match new RequestItem return signature.
broker/lms/lms_adapter.go Updates LmsAdapter interface signatures (RequestItem returns values; CheckOutItem param renamed).
broker/lms/lms_adapter_ncip.go Implements parsing/returning barcode + call number from NCIP RequestItemResponse; renames CheckOutItem param.
broker/lms/lms_adapter_manual.go Updates manual adapter stubs to satisfy new interface signatures.
broker/lms/lms_adapter_test.go Extends tests/mocks to validate the new RequestItem return values.

Comment on lines +531 to +535
itemBarcode := illRequest.BibliographicInfo.SupplierUniqueRecordId // TODO: read from item table
requestId := illRequest.Header.RequestingAgencyRequestId
userId := lmsAdapter.InstitutionalPatron(pr.RequesterSymbol.String)
// TODO set these values properly
externalReferenceValue := ""
err := lmsAdapter.CheckOutItem(requestId, itemId, userId, externalReferenceValue)
err := lmsAdapter.CheckOutItem(requestId, itemBarcode, userId, externalReferenceValue)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

itemBarcode is assigned from SupplierUniqueRecordId, but that field is also used as a bibliographic/record identifier elsewhere (e.g., RequestItem input). Renaming it to itemBarcode here is misleading until the actual barcode is retrieved from storage; consider keeping itemId (or similar) until the item table integration is done, to avoid accidental misuse.

Copilot uses AI. Check for mistakes.
Comment on lines +222 to +229
response, err := l.ncipClient.RequestItem(arg)
if err != nil {
return "", "", err
}
barCode := ""
callNumber := ""
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

response is dereferenced without checking for nil. Since the NcipClient interface allows returning (nil, nil), this can panic if an implementation (or future mock) returns a nil response with no error. Consider explicitly handling response == nil as an error (or returning empty values).

Copilot uses AI. Check for mistakes.
Comment on lines +228 to +229
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

The code treats ItemDescription.CopyNumber as the item barcode. In NCIP responses the item identifier is typically available via RequestItemResponse.ItemId.ItemIdentifierValue; CopyNumber is usually a copy/enumeration value and may not be a barcode. Consider preferring response.ItemId when present and using CopyNumber only as a fallback (if at all).

Suggested change
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
// Prefer the primary item identifier from ItemId when available.
if response.ItemId != nil && response.ItemId.ItemIdentifierValue != "" {
barCode = response.ItemId.ItemIdentifierValue
}
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
// Use CopyNumber only as a fallback if no ItemId barcode is present.
if barCode == "" {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
}

Copilot uses AI. Check for mistakes.
Comment on lines +162 to +164
barCode, callNumber, err := ad.RequestItem("req1", "item1", "testuser", "pickloc", itemLocation)
assert.NoError(t, err)
assert.Equal(t, "123.456", barCode)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

Go naming: barCode should be barcode (initialisms/words are typically lowercased in mixedCase). Renaming will improve readability and consistency across the codebase, especially now that this value is part of the method contract.

Suggested change
barCode, callNumber, err := ad.RequestItem("req1", "item1", "testuser", "pickloc", itemLocation)
assert.NoError(t, err)
assert.Equal(t, "123.456", barCode)
barcode, callNumber, err := ad.RequestItem("req1", "item1", "testuser", "pickloc", itemLocation)
assert.NoError(t, err)
assert.Equal(t, "123.456", barcode)

Copilot uses AI. Check for mistakes.
Comment on lines +226 to +232
barCode := ""
callNumber := ""
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
callNumber = response.ItemOptionalFields.ItemDescription.CallNumber
}
return barCode, callNumber, err
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

Go naming: barCode should be barcode (and similarly callNumber is fine). This local variable name is now part of the core RequestItem implementation, so keeping it idiomatic will help avoid spreading inconsistent casing to callers/tests.

Suggested change
barCode := ""
callNumber := ""
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
callNumber = response.ItemOptionalFields.ItemDescription.CallNumber
}
return barCode, callNumber, err
barcode := ""
callNumber := ""
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barcode = response.ItemOptionalFields.ItemDescription.CopyNumber
callNumber = response.ItemOptionalFields.ItemDescription.CallNumber
}
return barcode, callNumber, err

Copilot uses AI. Check for mistakes.
return actionExecutionResult{status: status, result: result, outcome: ActionOutcomeFailure, pr: pr}
}
// TODO: store barCode in item table and use it in CheckOutItem
ctx.Logger().Info("RequestItem response", "itemBarcode", itemBarcode, "callNumber", callNumber)
Copy link

Copilot AI Mar 6, 2026

Choose a reason for hiding this comment

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

This adds an INFO log on the normal (successful) RequestItem path. In this service there are no other INFO logs for routine operations, and this may create noisy logs and potentially expose item identifiers in production. Consider removing this log, downgrading it to DEBUG, or attaching these values to the transaction/event result instead of stdout logs.

Suggested change
ctx.Logger().Info("RequestItem response", "itemBarcode", itemBarcode, "callNumber", callNumber)

Copilot uses AI. Check for mistakes.
barCode := ""
callNumber := ""
if response.ItemOptionalFields != nil && response.ItemOptionalFields.ItemDescription != nil {
barCode = response.ItemOptionalFields.ItemDescription.CopyNumber
Copy link
Contributor

Choose a reason for hiding this comment

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

@adamdickmeiss this is wrong, FOLIO at least returns the barcode as:

<ns1:ItemId>
      <ns1:ItemIdentifierType ns1:Scheme="Scheme">Item Barcode</ns1:ItemIdentifierType>
      <ns1:ItemIdentifierValue>tl-b02</ns1:ItemIdentifierValue>
</ns1:ItemId>

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