Bug 399610 - Runtime Error: The KDE Project database could not be understood because of invalid character
Summary: Runtime Error: The KDE Project database could not be understood because of in...
Status: RESOLVED UPSTREAM
Alias: None
Product: kdesrc-build
Classification: Developer tools
Component: project metadata (show other bugs)
Version: Git
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Michael Pyne
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-10 13:01 UTC by Gregor Mi
Modified: 2018-10-16 22:31 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gregor Mi 2018-10-10 13:01:16 UTC
$ kdesrc-build --version
kdesrc-build 18.04 (v18.04-21-g0fe9920)

This file (added to git 04 Oct 2018)
kde/src/sysadmin/repo-metadata/projects/extragear/utils/keurocalc/metadata.yaml
contains this text:

    members:
    - displayname: Éric Bischoff

The É causes this error:

kdesrc-build encountered an exceptional error condition:
 ========
    Runtime Error: The KDE Project database could not be understood: Line      : 5
Column    : 15
Expected  : ALIAS DOUBLEQUOTE FLOWMAP_START FLOWSEQ_START FOLDED LITERAL PLAIN SINGLEQUOTE
Got       : Invalid plain scalar
Where     : /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP/Parser.pm line 490
YAML      : "\x{c9}ric Bischoff\n"
  at /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP/Loader.pm line 59.
 at /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP/Parser.pm line 100, <$fh> line 5.
        YAML::PP::Parser::parse(YAML::PP::Parser=HASH(0x55a1fae85798), "metadata.yaml") called at /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP/Loader.pm line 59
        YAML::PP::Loader::load(YAML::PP::Loader=HASH(0x55a1fae6fdd0), "metadata.yaml") called at /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP/Loader.pm line 50
        YAML::PP::Loader::load_file(YAML::PP::Loader=HASH(0x55a1fae6fdd0), "metadata.yaml") called at /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP.pm line 91
        YAML::PP::load_file(YAML::PP=HASH(0x55a1fae8c7e8), "metadata.yaml") called at /usr/lib/perl5/vendor_perl/5.26.2/YAML/PP.pm line 128
        YAML::PP::LoadFile("metadata.yaml") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/KDEProjectsReader.pm line 85
        ksb::KDEProjectsReader::_readYAML(ksb::KDEProjectsReader=HASH(0x55a1fabdf8a8), "metadata.yaml") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/KDEProjectsReader.pm line 76
        ksb::KDEProjectsReader::__ANON__() called at /usr/lib/perl5/5.26.2/File/Find.pm line 416
        File::Find::_find_dir(HASH(0x55a1fabdfa28), "/home/gregor/kde/src/sysadmin/repo-metadata/projects", 18) called at /usr/lib/perl5/5.26.2/File/Find.pm line 236
        File::Find::_find_opt(HASH(0x55a1fabdfa28), "/home/gregor/kde/src/sysadmin/repo-metadata/projects") called at /usr/lib/perl5/5.26.2/File/Find.pm line 760
        File::Find::find(CODE(0x55a1fabdfc20), "/home/gregor/kde/src/sysadmin/repo-metadata/projects") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/KDEProjectsReader.pm line 78
        ksb::KDEProjectsReader::_readProjectData(ksb::KDEProjectsReader=HASH(0x55a1fabdf8a8), ksb::Module=HASH(0x55a1fab8dff8)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/KDEProjectsReader.pm line 60
        ksb::KDEProjectsReader::new("ksb::KDEProjectsReader", ksb::Module=HASH(0x55a1fab8dff8), "git") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/BuildContext.pm line 987
        ksb::BuildContext::getProjectDataReader(ksb::BuildContext=HASH(0x55a1f8f22d98)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleSet/KDEProjects.pm line 126
        ksb::ModuleSet::KDEProjects::_expandModuleCandidates(ksb::ModuleSet::KDEProjects=HASH(0x55a1fab37b50), ksb::BuildContext=HASH(0x55a1f8f22d98), "konsole") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleSet/KDEProjects.pm line 205
        eval {...} called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleSet/KDEProjects.pm line 204
        ksb::ModuleSet::KDEProjects::convertToModules(ksb::ModuleSet::KDEProjects=HASH(0x55a1fab37b50), ksb::BuildContext=HASH(0x55a1f8f22d98)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleResolver.pm line 415
        ksb::ModuleResolver::expandModuleSets(ksb::ModuleResolver=HASH(0x55a1fabd0108), ksb::ModuleSet::KDEProjects=HASH(0x55a1fab37b50)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleResolver.pm line 140
        ksb::ModuleResolver::_expandSingleModuleSet(ksb::ModuleResolver=HASH(0x55a1fabd0108), ksb::ModuleSet::KDEProjects=HASH(0x55a1fab37b50)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleResolver.pm line 267
        ksb::ModuleResolver::_expandAllUnexpandedModuleSets(ksb::ModuleResolver=HASH(0x55a1fabd0108)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleResolver.pm line 290
        ksb::ModuleResolver::_resolveGuessedModules(ksb::ModuleResolver=HASH(0x55a1fabd0108), ksb::Module=HASH(0x55a1fabdf548)) called at /home/gregor/kde/src/kdesrc-build/modules/ksb/ModuleResolver.pm line 365
        ksb::ModuleResolver::resolveSelectorsIntoModules(ksb::ModuleResolver=HASH(0x55a1fabd0108), "gwenview") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/Application.pm line 446
        ksb::Application::generateModuleList(ksb::Application=HASH(0x55a1fa5bed68), "gwenview") called at /home/gregor/kde/src/kdesrc-build/modules/ksb/Application.pm line 64
        ksb::Application::new("ksb::Application", "gwenview") called at /home/gregor/bin/kdesrc-build line 271
        eval {...} called at /home/gregor/bin/kdesrc-build line 270

 ========
        Can't continue, so stopping now.


Change this lines to

    members:
    - displayname: ric Bischoff

fixes the error.
Comment 1 Ben Cooksley 2018-10-11 08:18:31 UTC
Mangling Éric's name in this case is the wrong thing to do I think.

Please check the LANG value on your system, along with the output of "locale" to ensure that you are running a UTF-8 locale.
Comment 2 Gregor Mi 2018-10-12 07:36:26 UTC
With removing the É from the name I just wanted to show that this causes the error. I also think that this is not the right way to solve the problem.

Here my locale output:

$ locale
LANG=de_DE.UTF-8
LC_CTYPE=en_US.UTF-8
LC_NUMERIC="de_DE.UTF-8"
LC_TIME="de_DE.UTF-8"
LC_COLLATE="de_DE.UTF-8"
LC_MONETARY="de_DE.UTF-8"
LC_MESSAGES="de_DE.UTF-8"
LC_PAPER="de_DE.UTF-8"
LC_NAME="de_DE.UTF-8"
LC_ADDRESS="de_DE.UTF-8"
LC_TELEPHONE="de_DE.UTF-8"
LC_MEASUREMENT="de_DE.UTF-8"
LC_IDENTIFICATION="de_DE.UTF-8"
LC_ALL=

$ echo $LANG
de_DE.UTF-8
Comment 3 Ben Cooksley 2018-10-12 10:19:51 UTC
Hmm. Not sure what to do in that case.

Michael, do we need to encode all the names in the metadata.yaml files that use non-ASCII characters to keep Perl's YAML interpreter happy?

(Python doesn't seem to mind UTF-8)
Comment 4 Michael Pyne 2018-10-13 19:13:53 UTC
(In reply to Ben Cooksley from comment #3)
> Hmm. Not sure what to do in that case.
> 
> Michael, do we need to encode all the names in the metadata.yaml files that
> use non-ASCII characters to keep Perl's YAML interpreter happy?
> 
> (Python doesn't seem to mind UTF-8)

No, UTF-8 should be quite acceptable, there shouldn't need to be an ASCII requirement here.

Gregor, does installing the Perl YAML::XS module fix the issue? It's something to the effect of libyaml-libyaml-perl on Debian distros.

YAML::PP appears to suppose utf-8, but I might not be passing the utf-8 encoding information right in Perl.
Comment 5 Michael Pyne 2018-10-13 19:29:07 UTC
YAML::XS does indeed work fine. I can reproduce the error by forcing the use of YAML::PP.

So a decent workaround for now is YAML::XS, but I will see about ensuring YAML::PP can work as well, or remove it as an option.
Comment 6 Michael Pyne 2018-10-13 21:14:39 UTC
I think this is a YAML::PP bug, but it is possible to adjust metadata.yaml to allow Éric's name to still be spelled properly:

    diff --git a/projects/extragear/utils/keurocalc/metadata.yaml b/projects/extragear/utils/keurocalc/metadata.yaml
    index 2f89c70..f706b2f 100644
    --- a/projects/extragear/utils/keurocalc/metadata.yaml
    +++ b/projects/extragear/utils/keurocalc/metadata.yaml
    @@ -2,7 +2,7 @@ description: Utility to handle currency conversions between European currencies
     hasrepo: true
     icon: null
     members:
    -- displayname: Éric Bischoff
    +- displayname: "Éric Bischoff"
       username: bischoff
     name: KEuroCalc
     projectpath: extragear/utils/keurocalc

Putting the string in quotes makes clear to YAML::PP that it's a string and not some other potential bit of YAML syntax. All the online validators I can find claim the original was valid YAML, and the spec itself seems to confirm that as well (allowing any printable Unicode character to be part of a "plain scalar").

Interestingly, using "☃ric Bischoff" as the name, without quotes, *also* works with YAML::PP. So I suspect this is an instance of the Perl "Unicode bug" affecting strings that have characters in the range U+0080-U+0100; these are treated internally as local-8-bit strings instead of utf8 by default and this has some implications for how other Perl operators process those strings even if they were read in as utf8.
Comment 7 Michael Pyne 2018-10-13 22:46:10 UTC
I've reported a bug against YAML::PP (at what appears to be the right upstream) with a testcase: https://github.com/perlpunk/YAML-PP-p5/issues/5

In the meantime Ben has committed a workaround that should permit kdesrc-build to work again. Thanks for the report, I wouldn't have noticed because I use YAML::XS myself.
Comment 8 Gregor Mi 2018-10-15 13:22:16 UTC
I installed YAML::XS with

    sudo zypper in perl-YAML-LibYAML

Now, the KDE project database can now be parsed even without the ""

    -- displayname: Éric Bischoff           <---------
    +- displayname: "Éric Bischoff"

Side note: "one of (YAML::XS, YAML::PP, YAML::Syck)" I always skipped YAML::XS because it was not obvious which package to choose, see some of the output of $ zypper se perl-yaml


S  | Name                          | Summary                                               | Type      
---+-------------------------------+-------------------------------------------------------+-----------
   | perl-YAML                     | YAML Ain't Markup Language™                           | package   
   | perl-YAML-LibYAML             | Perl YAML Serialization using XS and libyaml          | package   
   | perl-YAML-PP                  | YAML 1.2 processor                                    | package   
   | perl-YAML-Perl                | Pure Perl YAML Implementation                         | package   
   | perl-YAML-Syck                | Fast, lightweight YAML loader and dumper              | package   
   | perl-YAML-Tiny                | Read/Write YAML files with as little code as possible | package
Comment 9 Michael Pyne 2018-10-16 22:31:06 UTC
Thanks for the update. If it helps, it's already fixed upstream. https://github.com/perlpunk/YAML-PP-p5/commit/48a79a4190d52ab280b0f5296e81298b8424419a