erlef / rebar3_hex

Rebar3 Hex library
Apache License 2.0
101 stars 49 forks source link

Wrong error message when "re-publishing" #178

Closed eproxus closed 4 years ago

eproxus commented 4 years ago

When trying to publish again in under one hour after first publish, the following error message is shown:

===> Failed to publish package: Validation error(s)
        Inserted At: can only modify a release up to one hour after creation

However, if one does rebar3 hex revert <mypackage> <version> and then publishes again, it works. Thus the error message is wrong.

starbelly commented 4 years ago

@eproxus I think this has to be fixed up in hexpm. In this case we merely take what hex api gives us back and return it the user.

starbelly commented 4 years ago

@eproxus Ahh, the solution is here to use the --replace switch. It used to be you could modify a release under one hour from creation without additional flags, that has changed... so now you provide --replace

$ rebar3 hex publish 
===> Verifying dependencies...
Publishing truecoat 0.42.1 to hexpm
  Description: It gets installed at the factory
  Dependencies:

  Included files:
    LICENSE
    README.md
    rebar.config
    rebar.lock
    src/truecoat.app.src
    src/truecoat.erl
  Licenses: Apache 2.0
  Links:

  Build tools: rebar3
Be aware, you are publishing to the public Hexpm repository.
Before publishing, please read Hex CoC: https://hex.pm/policies/codeofconduct
Proceed? ("Y")> y
Local Password:
===> Failed to publish package: Validation error(s)
    Inserted At: can only modify a release up to one hour after creation

$ rebar3 hex publish --replace  
===> Verifying dependencies...
Publishing truecoat 0.42.1 to hexpm
  Description: It gets installed at the factory
  Dependencies:

  Included files:
    LICENSE
    README.md
    rebar.config
    rebar.lock
    src/truecoat.app.src
    src/truecoat.erl
  Licenses: Apache 2.0
  Links:

  Build tools: rebar3
Be aware, you are publishing to the public Hexpm repository.
Before publishing, please read Hex CoC: https://hex.pm/policies/codeofconduct
Proceed? ("Y")> y
Local Password:
===> Published truecoat 0.42.1
===> Published docs for truecoat 0.42.1

Going to close this as resolved. Please re-open if you have further problems.

eproxus commented 4 years ago

@starbelly Thanks for looking into it! Will the error message be changed? As it is now I think it is misleading

starbelly commented 4 years ago

@eproxus I thought about this last night, and yeah I think the error message should change. It'll be odd intercepting on our end, but we can... basically we should at least tell the user to use the --replace switch to modify in an under an hour.

starbelly commented 4 years ago

hmm @eproxus it seems per https://github.com/hexpm/hexpm/blob/59ebeee5b1c5a2f5ee1b1af41fbc270fbdd9a3b8/lib/hexpm/repository/release.ex#L142 that the message changes depending on the context. If it is public, then you get the message as reported in this issue, if it is private you get a message nudging you to use --replace. Obviously, this is the path hexpm wants users to go down so I'm unsure about telling users to use --replace in the message if that's a bad path.

Curious what @ericmj has to say on this.

ericmj commented 4 years ago

We should always show the error message hinting towards the --replace flag if you are within the grace period time window: https://github.com/hexpm/hexpm/pull/970.

starbelly commented 4 years ago

@ericmj 👍

Closing this as resolved.