-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Fix incorrect behavior on package rename #135
Fix incorrect behavior on package rename #135
Conversation
Maybe the original intent was to simply check if the new name was available before trying to publish it? I wonder if any of this is lost in translation from the CoffeeScript, and the callback-based era of the code in general (maybe lost in translation from decaf and/or the Promisification). In either case, it's not immediatley intuitive what we need to do. But I think we most essentially need to:
I'm looking through the code now trying to puzzle it out. |
No, because that code path is hit in all scenarios, including publishing a new version without renaming the package.
Luckily, the backend handles that part. When it sees that the package metadata has a name that doesn't match the name in the URL, it will check to see if the new name is available; if not, it'll return an HTTP error. That's the fix that we're making in this PR. |
The old package name continues to exist in the Edit: I'm using present tense here, but the status quo of |
Okay. Would love to see that backend fix land, and we can end-to-end test renames working before/rather than sort of blind-landing this one. The fix seems quite sensible from what you're saying. But when I test it, the end-user-apparent behavior is the same before/after the fix. (Assuming the end-user isn't I went ahead and looked at pulsar-edit/package-backend#271, reviewed what was said there and the code fix, left an Approve. I hope to see that one land, and we can confirm 100% that this one is working. If you don't mind that's the preferable order of things for me, especially if it looks like pulsar-edit/package-backend#271 is going to land anyway. Feel free to apprise me of any changes in proceedings or argue another case on how to see it. And thanks for the diligent issue-sleuthing and patching things up. Some |
Of course! Makes perfect sense. @confused-Techie, I'd love to get this PPM fix into the next release, so if you can find the time to land package-backend#271 in the next few days, that'd give us plenty of time to verify this behavior. |
I've been able to test and confirm this (alongside pulsar-edit/package-backend#271 now that it has landed and is live) does make the renaming process link the two package records in some way. Particularly: Now that I renamed my test package [...]1823481346 to [...]1823481347, using Confusing terminology of how to describe this aside, and with certain details still up for discussion of how the best user experience and backend/frontend approach to handling this all is, this aligns with the previous expectation, which must have subtly broken at some point. tl;dr: the fix works. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am approving on the basis that the dual issue between the backend and ppm has been discussed enough that we have multiple people satisfied with this outcome, and on the basis that, in my testing, this works in alignment with the expectation established from that discussion. Which for the record, it has been argued simply follows from continuity with how apm and the original Atom package back end would have worked.
Without getting into the weeds of sleuthing through old code, it seems plausible this is more or less how it used to work, but perhaps more importantly, it's a way we're comfortable with it working now.
I implicitly trust that the new spec works, since the actual new src/ code does work in my testing.
Likewise, I don't really use eslint ever, but for those who do use it, and since we already had this file, we may as well update it for the current state of the repo -- I am once again implicitly trusting that the update to that file is fine.
Okay tl;dr Looks Good To Me, Approved.
(We can merge this and get the ppm updates into core. Since I've been directly involved with both PR's, I can be an easy approve for that, and we can try to get another approve on that if you want to. Either way.)
Merging, thanks for the fix! |
Suppose a user maintains a package called
old-name
and wants to rename it tonew-name
. When the user runsppm
does these things (and other things, but these are the ones relevant to this discussion):name
field inpackage.json
to the new value (in fact, it will scold you if you try to do this manually); then/api/packages/old-name/versions/
with thepackage.json
metadata;/api/packages/
with that same metadata (since this is a brand-new publish of a package).If, in this scenario, the API got confused and told us that the package didn't exist, we'd end up treating this rename task as the publishing of a brand-new package.
new-name
would get published, but the API would not understand that it had anything to do withold-name
.As you might've guessed, that's exactly what is happening. It's happening because we end up asking the API if
new-name
already exists, notold-name
! This guarantees thatppm publish [tag] --rename
won't ever work.The fix is easy — since we already keep track of the original name, we'll ask the API whether the original name exists.
I've tested this fix locally to ensure it hits the proper code path. In my test, the server responded with an error, but we can sort that out later.
I wrote new specs for this behavior. I also took this opportunity to clean up this repo's
.eslintrc.js
file; it referenced several plugins that weren't even installed.