Code Monkey home page Code Monkey logo

Comments (2)

HebaruSan avatar HebaruSan commented on August 15, 2024

As noted elsewhere, the obstacle here isn't the lack of pulling the data (that code already exists), but the way the validation works; the NetkanValidator that runs on .netkan files before they're inflated performs the license validation checks:

new LicensesValidator(),

... which include making sure the license is defined:

if (licenses == null || licenses.Count < 1)
{
throw new Kraken("License should match spec");
}

If the licenses validator was removed from the netkan validator (and added to the ckan validator), the existing transformers would populate missing licenses as-is:

// GitHub says NOASSERTION if it can't figure out the repo's license
if (!string.IsNullOrWhiteSpace(ghRepo.License?.Id)
&& ghRepo.License.Id != "NOASSERTION")
{
json.SafeAdd("license", ghRepo.License.Id);
}

// SD provides users with the following default selection of licenses. Let's convert them to CKAN
// compatible license strings if possible.
//
// "MIT" - OK
// "BSD" - Specific version is indeterminate
// "GPLv2" - Becomes "GPL-2.0"
// "GPLv3" - Becomes "GPL-3.0"
// "LGPL" - Specific version is indeterminate
var sdLicense = sdMod.license.Trim();
switch (sdLicense)
{
case "GPLv2":
json.SafeAdd("license", "GPL-2.0");
break;
case "GPLv3":
json.SafeAdd("license", "GPL-3.0");
break;
default:
json.SafeAdd("license", sdLicense);
break;
}

Note that many or most of the licenses on SpaceDock are invalid and have to be massaged to get them to match the corresponding string in the CKAN schema. The most common issue is that SD uses a space where the schema uses a -, which the SpaceDock adder fixes here:

https://github.com/KSP-CKAN/NetKAN-Infra/blob/99896de590583914c5155330391c694e92653110/netkan/netkan/spacedock_adder.py#L146C14-L146C21

from ckan.

HebaruSan avatar HebaruSan commented on August 15, 2024

This is as far back as I was able to trace the licence-in-netkan requirement check; the very first commit creating metadata.t almost 10 years ago:

https://github.com/KSP-CKAN/NetKAN/blob/479eebd1063e5fec83df644cd043502c89fc1327/t/metadata.t#L23-L29

And here's where pjf explained it:

#346 (comment)

Because our tests don't actually do any netkan inflation, the second can report a missing license when we'd inflate it just fine (eg: when the KerbalStuff license is a valid license string in our spec). In those cases, one can set "x_netkan_license_ok" : true to disable the check.

It sounds like they were getting a lot of user-composed netkans with license set to an invalid string (and they couldn't validate after inflation, because at that time there wasn't any inflation), and those needed to get caught, and the field was made required as well as a side effect...? I guess because the check was just a dictionary look-up, with no explicit check for absent or null:

    my $mod_license = $metadata->{license} // "(none)";


    ok(
        $metadata->{x_netkan_license_ok} || $licenses{$mod_license},
        "$shortname license ($mod_license) should match spec. Set `x_netkan_license_ok` to supress."
    );
}

Based on that, I think I can finally confidently say that there isn't a deeper reason for why this is required in the netkan, and it's safe to change it. 🎉

from ckan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.