mirror of
https://github.com/apple/pkl.git
synced 2026-03-02 06:07:43 +01:00
project package throws InvalidAlgorithmParameterException when adding Package.apiTests
#108
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @StefMa on GitHub (Mar 8, 2024).
Given this source code:
9d5b220b0aIf you checkout the code and run
pkl test tests/*.pklit runs the tests and they pass.If you package the code, it works as well
./pkl project package.As soon as you uncomment line 9 in
PklProject(enablingapiTests) and run thepackagecommand, the tests pass but afterwards it throws an exception:InvalidAlgorithmParameterException
I have the feeling the
baseUriis not correct.But actually I also don't know what should be a current
basiUri.I also tried
package://pkg.pkl-lang.org/github.com/stefma/pkl-gha/\(name)(which sounds to me more correct)or even set a "valid"
version(0.0.1).Still no success, same error but with a different URL:
All of this sounds strange to me for two reasons:
packageI do a new release, obvious that this is not yet available.@bioball commented on GitHub (Mar 8, 2024):
The
packagecommand will check if there is already an existing package that exists, but with a different checksum. If it exists, it means that you need to bump your package's version.You can disable this behavior using the flag
--skip-publish-check.The error that you're seeing suggests that you've set up Pkl with custom CA certificates, but there are problems with your custom certificates.
Do you have a
~/.pkl/cacertsdirectory on your machine? If so, you will want to ensure that it has all of the root certs that you intend to trust.@odenix commented on GitHub (Mar 8, 2024):
Could you check if Pkl built from the main branch gives a better error message that doesn't include "Would you mind filing a bug report?"? I'm asking because my
HttpClientPR was recently merged.@StefMa commented on GitHub (Mar 9, 2024):
@bioball
But, why does this only happen when I add the
apiTestsconfig? 🤔Shouldn't it do it all the time?
Hmm.. How do i set up such a certificate? If I did so, I never did this on purpose actually.
Nope, its not there 🙃
@translatenix
I checked out
8dc258ef7d(This includes your changes).Then I build the cli with
./gradlew :pkl-cli:buildand runVERSION=0.0.1 /path/to/checkout/pkl-repo/pkl-cli/build/executable/jpkl project package.I still get an error, also still including the
An unexpected error has occurred. Would you mind filing a bug report?message 😬org.pkl.core.packages.PackageLoadError:
@StefMa commented on GitHub (Mar 14, 2024):
I did a closer look into this and found the following:
In case there is an
apiTestproperty in thePklProject, theProjectCommandcreates theCliProjectPackager.The
CliProjectPackagergets thebaseOptions(this is a instance ofCliBaseOptions) as arguments.The
baseOptionsfunction will callgetEffectiveCaCertificates()to populate the certificates.In my case, without a custom certificate, the "default" one from the resources directory.
The
CliProjectPackagerwill, in case thepackage.apiTestsproperty is available, create a new instance of theCliTestRunner.This
Runnergets a copy of theCliBaseOptions.The options, put to the
CliTestRunner, are just a copy of the same options as theCliProjectPackagerhave.Thus, it includes the same instance of the
caCertificatesproperty❗Since the base class of both (the
CliProjectPackagerand theCliTestRunner) is theCliCommand, which has ainitfunction that callsCertificateUtils.setupAllX509CertificatesGloballyfollowed byCertificateUtils.toInputStreamandCertificateUtils.generateCertificates, it will crash at this point because the exact same InputStream is used but thisInputStreamis already closed.This is my visual output (
printlndebugging 😁 ):This is the diff on top of
11f07d1ce8:I don't know where to fix this. Possible options would be:
emptyList())?InputStream?InputStream?Maybe this helps a bit 🙃
@odenix commented on GitHub (Mar 14, 2024):
FWIW,
CertificateUtilsis gone in HEAD.@StefMa commented on GitHub (Mar 14, 2024):
Didn't I said I tested your changes? 😖
I just tested it again with HEAD as well as the mentioned commit.
Seems to work now 🎉
Time for another release 🙃