Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registration failed: Internal Server Error at Metabase/Client/Simple.pm line 195. #3

Open
hakonhagland opened this issue Sep 17, 2023 · 10 comments · May be fixed by Perl-Toolchain-Gang/ExtUtils-MakeMaker#447

Comments

@hakonhagland
Copy link

I am trying to create a test report on Windows 11 using Strawberry Perl 5.38.0:

> cpan
cpan> install CPAN::Reporter
cpan> o conf init test_report
The goal of the CPAN Testers project (http://testers.cpan.org/) is to
test as many CPAN packages as possible on as many platforms as
possible.  This provides valuable feedback to module authors and
potential users to identify bugs or platform compatibility issues and
improves the overall quality and value of CPAN.

One way you can contribute is to send test results for each module
that you install.  If you install the CPAN::Reporter module, you have
the option to automatically generate and deliver test reports to CPAN
Testers whenever you run tests on a CPAN package.

See the CPAN::Reporter documentation for additional details and
configuration settings.  If your firewall blocks outgoing traffic,
you may need to configure CPAN::Reporter before sending reports.
 <test_report>
Generate test reports if CPAN::Reporter is installed (yes/no)? [no] yes
Would you like me configure CPAN::Reporter now? [yes]

Proceeding to configure CPAN::Reporter.

Some of the following configuration options require one or more "grade:action"
pairs that determine what grade-specific action to take for that option.
These pairs should be space-separated and are processed left-to-right. See
CPAN::Reporter documentation for more details.

    GRADE   :   ACTION  ======> EXAMPLES
    -------     -------         --------
    pass        yes             default:no
    fail        no              default:yes pass:no
    unknown     ask/no          default:ask/no pass:yes fail:no
    na          ask/yes
    default


CPAN::Reporter: no config file found; creating a new one.

CPAN::Reporter requires a valid email address to identify senders
in the body of a test report.  Please use a standard email format
like: "John Doe" <[jdoe@example.com](mailto:jdoe@example.com)>
email_from? [] "Håkon Hægland" <[hakon.hagland@gmail.com](mailto:hakon.hagland@gmail.com)>

Before test reports are sent, you may want to review or edit the test
report and add additional comments about the result or about your system
or Perl configuration.  By default, CPAN::Reporter will ask after
each report is generated whether or not you would like to edit the
report. This option takes "grade:action" pairs.

(Recommended: 'default:ask/no pass/na:no')
edit_report? [default:ask/no pass/na:no]

By default, CPAN::Reporter will prompt you for confirmation that
the test report should be sent before actually doing it. This
gives the opportunity to skip sending particular reports if
you need to (e.g. if you caused the failure). This option takes
"grade:action" pairs.

(Recommended: 'default:ask/yes pass/na:yes')

send_report? [default:ask/yes pass/na:yes]

CPAN::Reporter sends your reports over HTTPS using Metabase. This option lets
you set a different uri, transport mechanism and metabase profile path. If you
are receiving HTTPS errors, you may change the uri to use plain HTTP, though
this is not recommended. Unless you know what you're doing, just accept
the default value.

(Recommended: 'Metabase uri https://metabase.cpantesters.org/api/v1/ id_file metabase_id.json')
transport? [Metabase uri https://metabase.cpantesters.org/api/v1/ id_file metabase_id.json]

CPAN::Reporter: error loading Test::Reporter::Transport::Metabase. Please install the missing module or choose a different transport mechanism.


Would you like to run 'metabase-profile' now to create 'C:\Sp538CPT\data\.cpanreporter\metabase_id.json'? [y]
transport? [Metabase uri https://metabase.cpantesters.org/api/v1/ id_file metabase_id.json]

CPAN::Reporter: error loading Test::Reporter::Transport::Metabase. Please install the missing module or choose a different transport mechanism.

Would you like to run 'metabase-profile' now to create 'C:\Sp538CPT\data\.cpanreporter\metabase_id.json'? [y]
transport? [Metabase uri https://metabase.cpantesters.org/api/v1/ id_file metabase_id.json]

CPAN::Reporter: error loading Test::Reporter::Transport::Metabase. Please install the missing module or choose a different transport mechanism.

Would you like to run 'metabase-profile' now to create 'C:\Sp538CPT\data\.cpanreporter\metabase_id.json'? [y] n
You can create a Metabase profile by typing 'metabase-profile' in your
command prompt and moving the resulting file to the location you specified.
If you did not specify an absolute path, put it in your .cpanreporter
directory.  You will need to do this before continuing.

[NOTE: I here opened a new terminal window and ran "cpan Test::Reporter::Transport::Metabase" there first]

Would you like to run 'metabase-profile' now to create 'C:\Sp538CPT\data\.cpanreporter\metabase_id.json'? [y]
Running [C:\Sp538CPT\perl\site\bin\metabase-profile.BAT --output C:\Sp538CPT\data\.cpanreporter\metabase_id.json --email [hakon.hagland@gmail.com](mailto:hakon.hagland@gmail.com) --name Håkon Hægland --secret 0eb036c3]...
Writing profile to 'C:\Sp538CPT\data\.cpanreporter\metabase_id.json'

CPAN::Reporter: writing config file to 'C:\Sp538CPT\data\.cpanreporter\config.ini'.

Returning to CPAN configuration.

Please remember to call 'o conf commit' to make the config permanent!
cpan[3]> o conf commit
commit: wrote 'C:\Users\hakon\.cpan/CPAN/MyConfig.pm'
cpan> q

Then I tried to generate a report for File::Copy::Recursive::Reduced:

>cpan File::Copy::Recursive::Reduced
Loading internal logger. Log::Log4perl recommended for better logging
Reading 'C:\Users\hakon\.cpan\Metadata'
  Database was generated on Sun, 17 Sep 2023 10:41:02 GMT
Running install for module 'File::Copy::Recursive::Reduced'
CPAN: HTTP::Tiny loaded ok (v0.086)
CPAN: Net::SSLeay loaded ok (v1.92)
CPAN: IO::Socket::SSL loaded ok (v2.083)
Fetching with HTTP::Tiny:
https://cpan.org/authors/id/J/JK/JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
CPAN: Digest::SHA loaded ok (v6.04)
Fetching with HTTP::Tiny:
https://cpan.org/authors/id/J/JK/JKEENAN/CHECKSUMS
CPAN: Compress::Zlib loaded ok (v2.204)
Checksum for C:\Users\hakon\.cpan\sources\authors\id\J\JK\JKEENAN\File-Copy-Recursive-Reduced-0.007.tar.gz ok
CPAN: Archive::Tar loaded ok (v3.02)
CPAN: YAML loaded ok (v1.30)
CPAN: CPAN::Meta::Requirements loaded ok (v2.143)
CPAN: Parse::CPAN::Meta loaded ok (v2.150010)
CPAN: CPAN::Meta loaded ok (v2.150010)
CPAN: Module::CoreList loaded ok (v5.20230520)
Configuring J/JK/JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz with Makefile.PL
CPAN: CPAN::Reporter loaded ok (v1.2019)
Checking if your kit is complete...
Looks good
Generating a gmake-style Makefile
Writing Makefile for File::Copy::Recursive::Reduced
Writing MYMETA.yml and MYMETA.json
(C:\Sp538CPT\perl\bin\perl.exe Makefile.PL exited with 0)
CPAN::Reporter: Makefile.PL result is 'pass', No errors.
  JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
  C:\Sp538CPT\perl\bin\perl.exe Makefile.PL -- OK
Running make for J/JK/JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
cp lib/File/Copy/Recursive/Reduced.pm blib\lib\File\Copy\Recursive\Reduced.pm
(C:\Winlibs64-gcc11.3-msvcrt\mingw64\bin\gmake.EXE exited with 0)
CPAN::Reporter: gmake result is 'pass', No errors.
  JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
  C:\Winlibs64-gcc11.3-msvcrt\mingw64\bin\gmake.EXE -- OK
CPAN: CPAN::DistnameInfo loaded ok (v0.12)
Running make test for JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
"C:\Sp538CPT\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/*.t
t/001-fcopy.t .... ok
t/002-dircopy.t .. ok
t/003-rcopy.t .... ok
All tests successful.
Files=3, Tests=388,  2 wallclock secs ( 0.00 usr +  0.00 sys =  0.00 CPU)
Result: PASS
(C:\Winlibs64-gcc11.3-msvcrt\mingw64\bin\gmake.EXE test exited with 0)
CPAN::Reporter: Test result is 'pass', All tests successful.
CPAN::Reporter: preparing a CPAN Testers report for File-Copy-Recursive-Reduced-0.007
CPAN::Reporter: sending test report with 'pass' via Metabase
CPAN::Reporter: Test::Reporter: error from 'Test::Reporter::Transport::Metabase:'
registration failed: Internal Server Error at C:\Sp538CPT\perl\site\lib/Metabase/Client/Simple.pm line 195.
        Metabase::Client::Simple::register(Metabase::Client::Simple=HASH(0x21f598ef0b0)) called at C:\Sp538CPT\perl\site\lib/Metabase/Client/Simple.pm line 124
        Metabase::Client::Simple::submit_fact(Metabase::Client::Simple=HASH(0x21f598ef0b0), CPAN::Testers::Report=HASH(0x21f599259f8)) called at C:\Sp538CPT\perl\site\lib/Test/Reporter/Transport/Metabase.pm line 122
        Test::Reporter::Transport::Metabase::send(Test::Reporter::Transport::Metabase=HASH(0x21f4cf21038), Test::Reporter=HASH(0x21f5a4ea8b0)) called at C:\Sp538CPT\perl\site\lib/Test/Reporter.pm line 272
        eval {...} called at C:\Sp538CPT\perl\site\lib/Test/Reporter.pm line 272
        Test::Reporter::send(Test::Reporter=HASH(0x21f5a4ea8b0)) called at C:\Sp538CPT\perl\site\lib/CPAN/Reporter.pm line 495
        CPAN::Reporter::_dispatch_report(HASH(0x21f5a4dcc60)) called at C:\Sp538CPT\perl\site\lib/CPAN/Reporter.pm line 107
        CPAN::Reporter::grade_test(CPAN::Distribution=HASH(0x21f4cd940a8), "C:\\Winlibs64-gcc11.3-msvcrt\\mingw64\\bin\\gmake.EXE test", ARRAY(0x21f4cf1edd0), 0) called at C:\Sp538CPT\perl\site\lib/CPAN/Reporter.pm line 202
        CPAN::Reporter::test(CPAN::Distribution=HASH(0x21f4cd940a8), "C:\\Winlibs64-gcc11.3-msvcrt\\mingw64\\bin\\gmake.EXE test") called at C:\Sp538CPT\perl\lib/CPAN/Distribution.pm line 3854
        CPAN::Distribution::test(CPAN::Distribution=HASH(0x21f4cd940a8)) called at C:\Sp538CPT\perl\lib/CPAN/Distribution.pm line 4167
        CPAN::Distribution::install(CPAN::Distribution=HASH(0x21f4cd940a8)) called at C:\Sp538CPT\perl\lib/CPAN/Module.pm line 484
        eval {...} called at C:\Sp538CPT\perl\lib/CPAN/Module.pm line 483
        CPAN::Module::rematein(CPAN::Module=HASH(0x21f4abc53e0), "install") called at C:\Sp538CPT\perl\lib/CPAN/Module.pm line 592
        CPAN::Module::install(CPAN::Module=HASH(0x21f4abc53e0)) called at C:\Sp538CPT\perl\lib/CPAN/Shell.pm line 1901
        CPAN::Shell::rematein("install", "File::Copy::Recursive::Reduced") called at C:\Sp538CPT\perl\lib/CPAN/Shell.pm line 2068
        CPAN::Shell::__ANON__("File::Copy::Recursive::Reduced") called at C:/Sp538CPT/perl/lib/App/Cpan.pm line 635
        App::Cpan::__ANON__("File::Copy::Recursive::Reduced") called at C:/Sp538CPT/perl/lib/App/Cpan.pm line 652
        App::Cpan::_default(ARRAY(0x21f4cc61950), HASH(0x21f4d55f580)) called at C:/Sp538CPT/perl/lib/App/Cpan.pm line 536
        App::Cpan::run("App::Cpan", "File::Copy::Recursive::Reduced") called at C:\Sp538CPT\perl\bin/cpan.bat line 46


  JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
  C:\Winlibs64-gcc11.3-msvcrt\mingw64\bin\gmake.EXE test -- OK
Running make install for JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
Installing C:\Sp538CPT\perl\site\litb\File\Copy\Recursive\Reduced.pm
Appending installation info to C:\Sp538CPT\perl\lib/perllocal.pod
  JKEENAN/File-Copy-Recursive-Reduced-0.007.tar.gz
  C:\Winlibs64-gcc11.3-msvcrt\mingw64\bin\gmake.EXE install  -- OK

@jkeenan
Copy link

jkeenan commented Sep 17, 2023

I hope that this problem can be diagnosed, as that would facilitate getting more CPANtesters reports from Strawberry Perl users, which we sorely need.

@hakonhagland
Copy link
Author

Internal Server Error at C:\Sp538CPT\perl\site\lib/Metabase/Client/Simple.pm line 195.

Maybe this error should have been reported here https://github.com/cpan-testers/Metabase-Client-Simple instead? Anyway investigating this error a little bit closer:

See line 193 here:

https://github.com/cpan-testers/Metabase-Client-Simple/blob/7a3fe156b9c37bf23def68505b962113099a79c0/lib/Metabase/Client/Simple.pm#L193

I can reproduce the error using this minimal script:

use feature qw(say);
use strict;
use warnings;

use HTTP::Tiny;
use JSON::MaybeXS;

my $ua = HTTP::Tiny->new( agent => 'Metabase::Client::Simple/0.012 HTTP-Tiny/0.086');
my $req_uri = 'https://metabase.cpantesters.org/api/v1/register';
my $profile =  {
  'metadata' => {
      'core' => {
          'valid' => 1,
          'type' => 'Metabase-User-Profile',
          'resource' => 'metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd',
          'guid' => '6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd',
          'update_time' => '2023-09-17T14:13:50Z',
          'schema_version' => 1,
          'creator' => 'metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd',
          'creation_time' => '2023-09-17T14:13:50Z'
        }
    },
  'content' => '[{"metadata":{"core":{"valid":1,"type":"Metabase-User-FullName","resource":"metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd","guid":"6fecbfca-8700-1014-a9f1-b7b4bb8fb6bd","update_time":"2023-09-17T14:13:50Z","schema_version":1,"creator":"metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd","creation_time":"2023-09-17T14:13:50Z"}},"content":"H\\u00c2\\u0086kon H\\u00c2\\u0091gland"},{"metadata":{"core":{"valid":1,"type":"Metabase-User-EmailAddress","resource":"metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd","guid":"6fecc51b-8700-1014-a9f1-b7b4bb8fb6bd","update_time":"2023-09-17T14:13:50Z","schema_version":1,"creator":"metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd","creation_time":"2023-09-17T14:13:50Z"}},"content":"hakon.hagland@gmail.com"}]'
};
my $secret =  {
  'metadata' => {
      'core' => {
          'valid' => 1,
          'type' => 'Metabase-User-Secret',
          'resource' => 'metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd',
          'guid' => '6fecca94-8700-1014-a9f1-b7b4bb8fb6bd',
          'update_time' => '2023-09-17T14:13:50Z',
          'schema_version' => 1,
          'creator' => 'metabase:user:6fec4b9f-8700-1014-a9f1-b7b4bb8fb6bd',
          'creation_time' => '2023-09-17T14:13:50Z'
        }
    },
  'content' => '0eb036c3'
};
my @req = (
    $req_uri,
    {
        headers => {
            Content_Type => 'application/json',
            Accept       => 'application/json',
        },
        content => JSON::MaybeXS->new( { ascii => 1 } )
          ->encode( [ $profile, $secret ] ),
    }
);

my $res = $ua->post(@req);

use Data::Dumper qw(Dumper);
say Dumper($res);

The output is:

 {
          'success' => !!0,
          'url' => 'https://metabase.cpantesters.org/api/v1/register',
          'reason' => 'Internal Server Error',
          'status' => '500',
          'protocol' => 'HTTP/1.1',
          'headers' => {
                         'content-type' => 'text/html;charset=UTF-8',
                         'date' => 'Sun, 17 Sep 2023 18:25:36 GMT',
                         'server' => 'Mojolicious (Perl)',
                         'x-cache-hits' => '0, 0',
                         'accept-ranges' => 'bytes',
                         'connection' => 'keep-alive',
                         'x-served-by' => 'cache-lcy-eglc8600052-LCY, cache-osl6534-OSL',
                         'via' => '1.1 varnish, 1.1 varnish',
                         'x-cache' => 'MISS, MISS',
                         'content-length' => '18633',
                         'x-timer' => 'S1694975136.957567,VS0,VE330'
                       },
          'content' => '<!DOCTYPE html>
<!-- Request ID: d602851d -->
<html>
  <head>
 [...]
  </body>
</html>
'
        };

@hakonhagland
Copy link
Author

"content":"H\u00c2\u0086kon H\u00c2\u0091gland"

What encoding is this? It does not look like UTF-8

@hakonhagland
Copy link
Author

hakonhagland commented Sep 17, 2023

"content":"H\u00c2\u0086kon H\u00c2\u0091gland"

Yes it works if I replace this with:

"content":"Hakon Hagland"

I then get this result (success):

$VAR1 = {
          'url' => 'https://metabase.cpantesters.org/api/v1/register',
          'headers' => {
                         'content-type' => 'application/json;charset=UTF-8',
                         'x-timer' => 'S1694976876.857595,VS0,VE234',
                         'x-cache-hits' => '0, 0',
                         'via' => '1.1 varnish, 1.1 varnish',
                         'x-served-by' => 'cache-lcy-eglc8600056-LCY, cache-osl6523-OSL',
                         'date' => 'Sun, 17 Sep 2023 18:54:36 GMT',
                         'server' => 'Mojolicious (Perl)',
                         'connection' => 'keep-alive',
                         'content-length' => '22',
                         'accept-ranges' => 'bytes',
                         'x-cache' => 'MISS, MISS'
                       },
          'reason' => 'OK',
          'protocol' => 'HTTP/1.1',
          'success' => !!1,
          'status' => '200',
          'content' => '{"message":"accepted"}'
        };

so it might be an encoding issue?

@hakonhagland
Copy link
Author

hakonhagland commented Sep 17, 2023

"content":"H\u00c2\u0086kon H\u00c2\u0091gland"

I think this is related to my email user name "Håkon Hægland" containing norwegian letters "å" and "æ" and encoded first in code page 850 then reencoded in UTF-8. So "å" in DOS latin is 0x86 which when encoded as UTF-8 becomes 0xc2 0x86 and "æ" is 0x91 which when reencoded in UTF-8 becomes 0xc2 0x91

@hakonhagland
Copy link
Author

I think we might need to convert input read from the console (cpan console) to unicode somewehere. I created a question here that might be relevant: https://stackoverflow.com/q/77123411/2173773

@hakonhagland
Copy link
Author

we might need to convert input read from the console (cpan console) to unicode somewehere.

Seems like CPAN::Reporter uses CPAN::Shell which uses ExtUtils::MakeMaker to read from the console. So maybe the encoding fix needs to be applied somewhere in CPAN::Reporter ?

@hakonhagland
Copy link
Author

See also: cpan-testers/Metabase-Fact#6

@hakonhagland
Copy link
Author

Added a PR that might fix the issue, see Perl-Toolchain-Gang/ExtUtils-MakeMaker#447

@hakonhagland
Copy link
Author

Added two new PRs (cpan-testers/CPAN-Reporter#105 and cpan-testers/Metabase-Fact#10) that should help solve this issue in addition to Perl-Toolchain-Gang/ExtUtils-MakeMaker#447

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants