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

Api errors are propagated as plain strings using an unpleasant format #131

Open
borland opened this issue Aug 3, 2022 · 0 comments
Open
Assignees

Comments

@borland
Copy link
Collaborator

borland commented Aug 3, 2022

In situations where the Octopus Server returns an error, the core.APIErrorChecker function is run to validate the response.

This function has a hardcoded error template string format of "octopus deploy api returned an error on endpoint %s - %s", urlPath, octopusDeployError.Errors
Note: octopusDeployError.Errors is a []string, representing a JSON array that the server sent us in the error response.

This results in a caller, (e.g. the CLI) receiving a string such as the following:

octopus deploy api returned an error on endpoint /api/Spaces-1/releases/create/v1 - [Release '5.0.2' already exists for this project. Please use a different version, or look at using a mask to auto-increment the number.]

This is not particularly friendly for end-user display. The brute force option would be to regex or string-split to pull out the contents inside the [], however this is incredibly brittle.

My preferred option would be to have the APIErrorChecker return a richer error struct, which contained the server-sent strings in an array that could be accessed by the caller. This would enable the CLI to simply print the server-sent error: Release '5.0.2' already exists for this project. Please use a different version, or look at using a mask to auto-increment the number.

@borland borland self-assigned this Aug 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant