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

Error in pdk release publish #1210

Closed
coreone opened this issue Feb 14, 2023 · 6 comments
Closed

Error in pdk release publish #1210

coreone opened this issue Feb 14, 2023 · 6 comments
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor

Comments

@coreone
Copy link

coreone commented Feb 14, 2023

Describe the bug
When running pdk release publish, a Ruby error occurs when trying to call the URI method:

pdk (INFO): Releasing module-name - from version 4.0.0
pdk (INFO): Uploading tarball to puppet forge...
Traceback (most recent call last):
	10: from /usr/local/bin/pdk:23:in `<main>'
	 9: from /usr/local/bin/pdk:23:in `load'
	 8: from /var/lib/gems/2.7.0/gems/pdk-2.6.1/exe/pdk:6:in `<top (required)>'
	 7: from /var/lib/gems/2.7.0/gems/pdk-2.6.1/lib/pdk/cli.rb:71:in `run'
	 6: from /var/lib/gems/2.7.0/gems/cri-2.15.11/lib/cri/command.rb:316:in `run'
	 5: from /var/lib/gems/2.7.0/gems/cri-2.15.11/lib/cri/command.rb:316:in `run'
	 4: from /var/lib/gems/2.7.0/gems/cri-2.15.11/lib/cri/command.rb:298:in `run'
	 3: from /var/lib/gems/2.7.0/gems/cri-2.15.11/lib/cri/command.rb:362:in `run_this'
	 2: from /var/lib/gems/2.7.0/gems/pdk-2.6.1/lib/pdk/cli/release/publish.rb:47:in `block (2 levels) in <module:CLI>'
	 1: from /var/lib/gems/2.7.0/gems/pdk-2.6.1/lib/pdk/module/release.rb:91:in `run'
/var/lib/gems/2.7.0/gems/pdk-2.6.1/lib/pdk/module/release.rb:158:in `run_publish': undefined method `URI' for #<PDK::Module::Release:0x000055c4eac01340> (NoMethodError)

To Reproduce

  • Download version 2.6.1 of pdk
  • cd to a directory containing a pdk-configured repository
  • Run pdk release publish --skip-changelog --skip-dependency --skip-documentation --force --forge-token='abc123'

Expected behavior
This particular example should return an access denied error due to the use of a fake forge token. Using a real token should publish the module to the forge.

Additional context

  • Your PDK installation method: Gemfile (so, this is run with bundle exec)
    • (If via Rubygems, please include your Ruby version ruby -v): ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-linux-gnu]
  • Your PDK version (pdk --version): 2.6.1
  • Your operating system / platform: Ubuntu

** To fix the error **
It looks like the only thing needed to fix this issue is to include a require 'uri' at the top of the lib/pdk/module/release.rb file. When I do that locally in a test instance, running the pdk release publish --skip-changelog --skip-dependency --skip-documentation --force --forge-token='abc123' command returns as I would expect:

pdk (INFO): Releasing module-name - from version 4.0.0
pdk (INFO): Uploading tarball to puppet forge...
pdk (ERROR): Error uploading to Puppet Forge: {"message":"401 Unauthorized","errors":["The access token is not valid."],"error":"invalid_token","error_description":"The access token is not valid."}
@coreone coreone added bug needs-triage Newly created issue that has not been reviewed by a PDK contributor labels Feb 14, 2023
@chelnak
Copy link
Contributor

chelnak commented Feb 14, 2023

@coreone interesting find. I'm surprised this hasn't popped up before now.

We will investigate and get back to you shortly.

@coreone
Copy link
Author

coreone commented Feb 14, 2023

I edited the release.rb file and added require 'uri' to the top and then ran the command again and it deployed correctly:

# bundle exec pdk release publish --skip-changelog --skip-dependency --skip-documentation
pdk (INFO): Releasing module-name - from version 4.0.0
pdk (INFO): Uploading tarball to puppet forge...
pdk (INFO): Publish to Forge was successful

@chelnak
Copy link
Contributor

chelnak commented Feb 15, 2023

What I find interesting here is that URI should be available by default.

I'm triaging this right now and cannot replicate.

Just to confirm, are you running PDK as a gem via a modules Gemfile?

@coreone
Copy link
Author

coreone commented Feb 17, 2023

I have had an issue in a Debian-based container doing bundle install to install pdk and then using bundle exec pdk to run pdk after all the gems have been installed. The same issue occurs using a GitHub Action using the ruby/setup-ruby action to try to do the release as well. You should be able to see the configuration at:

https://github.com/broadinstitute/puppet-certificates

@chelnak
Copy link
Contributor

chelnak commented Feb 17, 2023

Interesting thanks for the additional info.

I'm actually working on removing the code causing you issues at the moment so hopefully this will be resolved in the next release.. however I'd like to get to the bottom of what is happening in your scenario and see if we can find a workaround.

chelnak added a commit that referenced this issue Mar 10, 2023
As reported in #1210, in some situations pdk will fail to publish a
module due to a missing require for URI.

For this specific occurance we will eventually move to the forge SDK
which will elimiate the issue. However, due to some dependency
constraints we cannot to that yet.

This change simply adds a new require for uri, which will solve the
issue described above until we are able to migrate to the Forge SDK.
@chelnak
Copy link
Contributor

chelnak commented Mar 10, 2023

Fixed in #1220

@chelnak chelnak closed this as completed Mar 10, 2023
LukasAud added a commit that referenced this issue Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs-triage Newly created issue that has not been reviewed by a PDK contributor
Projects
None yet
Development

No branches or pull requests

2 participants