Bug 40490

Summary: Warnings from GD::Barcode::QRcode on U24
Product: Koha Reporter: Jonathan Druart <jonathan.druart>
Component: Test SuiteAssignee: Jonathan Druart <jonathan.druart>
Status: Pushed to main --- QA Contact: Marcel de Rooy <m.de.rooy>
Severity: minor    
Priority: P5 - low CC: dcook, m.de.rooy
Version: unspecified   
Hardware: All   
OS: All   
GIT URL: Change sponsored?: ---
Patch complexity: Small patch Documentation contact:
Documentation submission: Text to go in the release notes:
Version(s) released in:
25.11.00
Circulation function:
Bug Depends on: 40348    
Bug Blocks:    
Attachments: Bug 40490: Remove warnings from GD::Barcode::QRcode - U24
Bug 40490: Remove warnings from GD::Barcode::QRcode - U24
Bug 40490: Remove warnings from GD::Barcode::QRcode - U24

Description Jonathan Druart 2025-07-24 05:27:59 UTC
01:18:38 koha_1       | #   Failed test 'no warnings'
01:18:38 koha_1       | #   at /usr/share/perl/5.38/Test/Builder.pm line 193.
01:18:38 koha_1       | # There were 6 warning(s)
01:18:38 koha_1       | #     Previous test 4 '401 Unauthorized'
01:18:38 koha_1       | #     Use of uninitialized value $aMask[1079] in bitwise xor (^) at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.
01:18:38 koha_1       | #  at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.

t/db_dependent/api/v1/two_factor_auth.t

jammy (22.04LTS) (perl): 1.15-7
noble (24.04LTS) (perl): 2.00-1

I guess it's fixed by 
https://github.com/mbeijen/GD-Barcode/commit/85e7911e65bf1c4746d9ce2e743580bbf51da793

But it is not released yet: version 2 is from September 2023 and commit from March 2024.
Comment 1 Jonathan Druart 2025-07-24 05:40:27 UTC
Created attachment 184575 [details] [review]
Bug 40490: Remove warnings from GD::Barcode::QRcode - U24

01:18:38 koha_1       | #   Failed test 'no warnings'
01:18:38 koha_1       | #   at /usr/share/perl/5.38/Test/Builder.pm line 193.
01:18:38 koha_1       | # There were 6 warning(s)
01:18:38 koha_1       | #     Previous test 4 '401 Unauthorized'
01:18:38 koha_1       | #     Use of uninitialized value $aMask[1079] in bitwise xor (^) at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.
01:18:38 koha_1       | #  at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.

jammy (22.04LTS) (perl): 1.15-7
noble (24.04LTS) (perl): 2.00-1

I guess it's fixed by
https://github.com/mbeijen/GD-Barcode/commit/85e7911e65bf1c4746d9ce2e743580bbf51da793

But it is not released yet: version 2 is from September 2023 and commit from March 2024.

Test plan:
Install version 2 of GD::Barcode:
  `cpanm GD::Barcode@2.0.0`
Run the tests
Without this patch the "no warnings" test fails
With this patch applied the tests pass
Comment 2 David Cook 2025-07-24 05:48:31 UTC
That's an interesting one.

I'll ask on their Github if they'd be willing to upload a new version to CPAN.
Comment 3 David Cook 2025-07-24 05:50:22 UTC
(In reply to David Cook from comment #2)
> That's an interesting one.
> 
> I'll ask on their Github if they'd be willing to upload a new version to
> CPAN.

https://github.com/mbeijen/GD-Barcode/issues/10
Comment 4 David Cook 2025-07-24 05:55:36 UTC
Created attachment 184576 [details] [review]
Bug 40490: Remove warnings from GD::Barcode::QRcode - U24

01:18:38 koha_1       | #   Failed test 'no warnings'
01:18:38 koha_1       | #   at /usr/share/perl/5.38/Test/Builder.pm line 193.
01:18:38 koha_1       | # There were 6 warning(s)
01:18:38 koha_1       | #     Previous test 4 '401 Unauthorized'
01:18:38 koha_1       | #     Use of uninitialized value $aMask[1079] in bitwise xor (^) at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.
01:18:38 koha_1       | #  at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.

jammy (22.04LTS) (perl): 1.15-7
noble (24.04LTS) (perl): 2.00-1

I guess it's fixed by
https://github.com/mbeijen/GD-Barcode/commit/85e7911e65bf1c4746d9ce2e743580bbf51da793

But it is not released yet: version 2 is from September 2023 and commit from March 2024.

Test plan:
Install version 2 of GD::Barcode:
  `cpanm GD::Barcode@2.0.0`
Run the tests
Without this patch the "no warnings" test fails
With this patch applied the tests pass

Signed-off-by: David Cook <dcook@prosentient.com.au>
Comment 5 David Cook 2025-07-24 06:01:42 UTC
I don't have a U24 system on hand, but the tests pass with the patch on D12, so there's no harm in them.

--

Looking at the code, I wonder if we could have used one of Test::Output's stderr_* methods here to check if STDERR was empty or had the error we expect in U24? But this should work fine.

I wonder how we'll know to undo this change when there's a newer version of GD::Barcode available? Would it be worth wrapping this in a GD::Barcode::VERSION check?
Comment 6 Jonathan Druart 2025-07-24 07:34:11 UTC
(In reply to David Cook from comment #5)
> Looking at the code, I wonder if we could have used one of Test::Output's
> stderr_* methods here to check if STDERR was empty or had the error we
> expect in U24? But this should work fine.

I had a look at it last week (because there is already an occurrence of a similar problem, see bug 18772), but it's yet another dependency and so I decided to keep the STDERR redirect. But I wouldn't mind adjusting them if we have more occurrences coming.

> I wonder how we'll know to undo this change when there's a newer version of
> GD::Barcode available? Would it be worth wrapping this in a
> GD::Barcode::VERSION check?

Yes, I thought about that (again for bug 18772) but didn't find an elegant solution.
What do you mean by "wrapping in a version check"? Only the expected output or to let us know the STDERR redirect can be removed?
Comment 7 David Cook 2025-07-24 23:21:02 UTC
(In reply to Jonathan Druart from comment #6)
> > I wonder how we'll know to undo this change when there's a newer version of
> > GD::Barcode available? Would it be worth wrapping this in a
> > GD::Barcode::VERSION check?
> 
> Yes, I thought about that (again for bug 18772) but didn't find an elegant
> solution.
> What do you mean by "wrapping in a version check"? Only the expected output
> or to let us know the STDERR redirect can be removed?

Yeah, letting us know when the STDERR redirect can be removed. I was thinking maybe we could do the STDERR redirect just for $GD::Barcode::VERSION == 2.00 or something like that, so that systems using older or newer versions of GD::Barcode would still get checked by Test::NoWarnings. Otherwise, I'm not sure when we'll know to come back to undo it. But it's just a thought.
Comment 8 David Cook 2025-07-24 23:24:53 UTC
(In reply to David Cook from comment #3)
> (In reply to David Cook from comment #2)
> > That's an interesting one.
> > 
> > I'll ask on their Github if they'd be willing to upload a new version to
> > CPAN.
> 
> https://github.com/mbeijen/GD-Barcode/issues/10

Michiel was super responsive, and he's uploaded a version 2.01 to CPAN with the fix.

Probably not worth packaging it ourselves just to solve this problem, but I'll ask the Debian maintainer if they can try out the new version, so that it flows through at some point.
Comment 9 David Cook 2025-07-24 23:35:32 UTC
(In reply to David Cook from comment #8)
> (In reply to David Cook from comment #3)
> > (In reply to David Cook from comment #2)
> > > That's an interesting one.
> > > 
> > > I'll ask on their Github if they'd be willing to upload a new version to
> > > CPAN.
> > 
> > https://github.com/mbeijen/GD-Barcode/issues/10
> 
> Michiel was super responsive, and he's uploaded a version 2.01 to CPAN with
> the fix.
> 
> Probably not worth packaging it ourselves just to solve this problem, but
> I'll ask the Debian maintainer if they can try out the new version, so that
> it flows through at some point.

I've emailed a Debian bug report asking for a version bump and potentially a backport. We'll see how that goes. It's not showing up on bugs.debian.org yet, but hopefully it will.
Comment 10 David Cook 2025-07-25 00:34:18 UTC
Looks like bug 18772 is another case where the bug is already fixed upstream but hasn't flowed through to CPAN and Debian. Weird.
Comment 11 Marcel de Rooy 2025-07-25 06:48:48 UTC
Having issues with get_session called in two_factor_auth.t.
Seems unrelated to this patch.
Getting no session while passing empty string?
Comment 12 Marcel de Rooy 2025-07-25 07:02:13 UTC
(In reply to Marcel de Rooy from comment #11)
> Having issues with get_session called in two_factor_auth.t.
> Seems unrelated to this patch.
> Getting no session while passing empty string?

Resolved. Interference with development on koha scripts, changing paths ;)
Comment 13 Marcel de Rooy 2025-07-25 07:07:59 UTC
Created attachment 184613 [details] [review]
Bug 40490: Remove warnings from GD::Barcode::QRcode - U24

01:18:38 koha_1       | #   Failed test 'no warnings'
01:18:38 koha_1       | #   at /usr/share/perl/5.38/Test/Builder.pm line 193.
01:18:38 koha_1       | # There were 6 warning(s)
01:18:38 koha_1       | #     Previous test 4 '401 Unauthorized'
01:18:38 koha_1       | #     Use of uninitialized value $aMask[1079] in bitwise xor (^) at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.
01:18:38 koha_1       | #  at /usr/share/perl5/GD/Barcode/QRcode.pm line 217.

jammy (22.04LTS) (perl): 1.15-7
noble (24.04LTS) (perl): 2.00-1

I guess it's fixed by
https://github.com/mbeijen/GD-Barcode/commit/85e7911e65bf1c4746d9ce2e743580bbf51da793

But it is not released yet: version 2 is from September 2023 and commit from March 2024.

Test plan:
Install version 2 of GD::Barcode:
  `cpanm GD::Barcode@2.0.0`
Run the tests
Without this patch the "no warnings" test fails
With this patch applied the tests pass

Signed-off-by: David Cook <dcook@prosentient.com.au>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 14 Jonathan Druart 2025-07-25 07:08:08 UTC
Thanks for all the upstream work, David!
Comment 15 Lucas Gass (lukeg) 2025-07-25 20:40:58 UTC
Nice work everyone!

Pushed to main for 25.11