Can't delete package via API but can via front-end

Jay's Avatar

Jay

20 Dec, 2017 07:06 AM

Hi OD,

I'm using the .Net client API to clean up our "trash" builds (builds we don't intend to deliver) as part of our build process once they reach a certain age. For the most part, it works fine. But attempts to delete some packages fail with an OctopusResourceNotFoundException.

To reproduce, I have the following code:

var a = repo.BuiltInPackageRepository.ListPackages("DA.Lending.Bizagi.Workflow", 0, int.MaxValue); var packageToDelete = a.Items.FirstOrDefault(p => string.Equals(p.Id, "packages-DA.Lending.Bizagi.Workflow.11.1.02181-DEV+20171206.4")); repo.BuiltInPackageRepository.DeletePackage(packageToDelete);

Note that I inspected "a" in a debug session to get the internal package Id and confirmed that "packageToDelete" is not null.

The DeletePackage call fails with OctopusResourceNotFoundException.

I've confirmed that the package in question is in the built-in package repository directory on the OD server. Full path is:

D:\Octopus\Packages\DA.Lending.Bizagi.Workflow\DA.Lending.Bizagi.Workflow.11.1.02181-DEV+20171206.4.zip

However, if I navigate to this package in the front-end, check the box and click the Delete button, it gets deleted.

Why come package deleted via front-end but API not do? Is it some difference in the logic between zip files and nuget packages? Maybe our crazy version numbering system is a little too crazy?

Cheers,

Jay

  1. Support Staff 1 Posted by Robert Wagner on 21 Dec, 2017 06:55 AM

    Robert Wagner's Avatar

    Hi Jay,

    Thank you for getting in touch. I knew what the problem was as soon as I saw the package name. There is a darn bug in our HTTP server stack (Nancy) that double decodes +. I've fixed up the problem for the delete endpoint, you can track the fix here. At this stage it will be included in the first release of the new year.

    The workaround is to use the bulk delete end point. I'm just in the process of adding that to Octopus.Client and version 4.29.0 should be out in the next couple of hours.

    Regards,

    Rob W

  2. 2 Posted by Jay on 21 Dec, 2017 10:16 PM

    Jay's Avatar

    Hey Rob,

    just got client 4.29.0 and switched over to DeletePackages for the time being. Great workaround, thanks for the fast response.

    Cheers,

    Jay

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac