Bug 40270 - Remove useless warnings on failed SIP2 login
Summary: Remove useless warnings on failed SIP2 login
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: SIP2 (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor
Assignee: Tomás Cohen Arazi (tcohen)
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-06-27 19:46 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2025-06-27 20:38 UTC (History)
3 users (show)

See Also:
GIT URL:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
Circulation function:


Attachments
Bug 40270: Fix uninitialized value warnings in SIP logging (2.67 KB, patch)
2025-06-27 19:50 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 40270: Fix uninitialized value warnings in SIP logging (2.72 KB, patch)
2025-06-27 20:38 UTC, David Nind
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2025-06-27 19:46:41 UTC
We see this consistently in the logs:

Use of uninitialized value $args[0] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314
Use of uninitialized value $args[1] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314
Comment 1 Tomás Cohen Arazi (tcohen) 2025-06-27 19:50:05 UTC
Created attachment 183631 [details] [review]
Bug 40270: Fix uninitialized value warnings in SIP logging

The SIP server generates warnings when logging account information
for failed logins:

Use of uninitialized value $args[0] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314
Use of uninitialized value $args[1] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314

This occurs when $self->{account}->{id} or $self->{account}->{institution}
are undefined during failed authentication attempts.

This patch fixes the issue by:
1. Adding a safer sprintf implementation in siplog that handles undefined values
2. Providing default values for undefined account information in logging calls

To test:
1. Start SIP server
2. Attempt to connect with invalid credentials using sip_cli_emulator.pl:
   ./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su invaliduser -sp wrongpass -l kohalibrary2 --patron koha -m patron_information
3. Check /var/log/koha/kohadev/sip-output.log
=> FAIL: 'Use of uninitialized value...' warns
4. Apply this patch
5. Repeat 2
=> SUCCESS: No "Use of uninitialized value" warnings appear
=> SUCCESS: Logging shows 'undef/undef' for failed logins instead of empty strings
6. Try a valid login
=> SUCCESS: Still works correctly for valid logins
7. Sign off :-D
Comment 2 David Nind 2025-06-27 20:38:04 UTC
Created attachment 183633 [details] [review]
Bug 40270: Fix uninitialized value warnings in SIP logging

The SIP server generates warnings when logging account information
for failed logins:

Use of uninitialized value $args[0] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314
Use of uninitialized value $args[1] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314

This occurs when $self->{account}->{id} or $self->{account}->{institution}
are undefined during failed authentication attempts.

This patch fixes the issue by:
1. Adding a safer sprintf implementation in siplog that handles undefined values
2. Providing default values for undefined account information in logging calls

To test:
1. Start SIP server
2. Attempt to connect with invalid credentials using sip_cli_emulator.pl:
   ./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su invaliduser -sp wrongpass -l kohalibrary2 --patron koha -m patron_information
3. Check /var/log/koha/kohadev/sip-output.log
=> FAIL: 'Use of uninitialized value...' warns
4. Apply this patch
5. Repeat 2
=> SUCCESS: No "Use of uninitialized value" warnings appear
=> SUCCESS: Logging shows 'undef/undef' for failed logins instead of empty strings
6. Try a valid login
=> SUCCESS: Still works correctly for valid logins
7. Sign off :-D

Signed-off-by: David Nind <david@davidnind.com>