Error fetching API keys

Using Octopus.Client 4.36.3 and Octopus Server 2018.1.3 we had trouble fetching API keys for a user:

$repository.Users.GetApiKeys($user)

Exception calling “GetApiKeys” with “1” argument(s): “The resource ‘apikeys’ was not found.”

After much digging we found the problem:

  • The user has 30+ API keys (automatically created on demand) which triggers paging
  • The “Page.All/Next/Current/Last” links are broken in REST API which causes the error

Example of broken links:

Request: /api/users/Users-64/apikeys
Response:

“Links”: {
“Self”: “/api/users/Users-64/apikeys”,
“Template”: “/api/users/{userId}/apikeys{/id}{?skip,take}”,
“Page.All”: “/api/users//apikeys?skip=0&take=2147483647”,
“Page.Next”: “/api/users//apikeys?skip=30&take=30”,
“Page.Current”: “/api/users//apikeys?skip=0&take=30”,
“Page.Last”: “/api/users//apikeys?skip=90&take=30”
}

See the “//”? Users-64 is missing! Definitely a bug if you ask me. :slight_smile:

Hi there,

Thanks for reaching out. Bug indeed! I’ve created a github issue for it which you can follow to get notified when we ship a fix: https://github.com/OctopusDeploy/Issues/issues/4608

Thanks for taking the time to report this :slight_smile: . Highly possible that you are the first user ever to create more than 30 API keys for a single user.

Best regards,
Dalmiro

:slight_smile: You’re welcome! Thank’s for making it easy to report bugs - and for the positive attitude upon receiving them.

:question: If we’re the first ones hitting the 30 key limit - are we doing something wrong? The use case is that we have automated setup of deployment pipelines involving both SCM, CI and deploy tools (the latter being OD). To give CI server access to OD for pushing packages we generate API keys and store them in the CI server. An alternative would be to generate unique service accounts for each pipeline.

What’s currently stopping you from having a unique service account with a unique API Key? I just want to make sure I understand your scenario properly :slight_smile:

BTW we’ve merged a fix for this which should go out in the next release https://github.com/OctopusDeploy/Issues/issues/4608

Nothing really stopping us from creating unique service accounts as it would be automated as well. We took the path with multiple API keys as we didn’t want to clutter the user directory with a lot of service accounts. As mentioned above, the need is merely to be able to have an API key in order to push packages to Octopus.

Thanks for the update! Glad we could help! :slight_smile:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.