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

Improve user facing error massage when the stack is not found #182

Conversation

mwasilew2
Copy link
Contributor

closes: https://app.clickup.com/t/862k09kgc

Includes in the error message a hint about how to list available stacks.

Note: The GraphQL API doesn't return errors that can be typed. The string parsing is a dirty hack, if anyone knows of a better way to approach it let me know.

@Clickup-user
Copy link

@mwasilew2 mwasilew2 changed the title chore: improve user facing error massage when the stack is not found Improve user facing error massage when the stack is not found Sep 27, 2023
@tomasmik
Copy link
Contributor

We have this function called getStackID which is called every time you do anything with a command which interacts with stacks: https://github.com/spacelift-io/spacectl/blob/main/internal/cmd/stack/stack_selector.go#L19

Because this is called every time we parse the provided --id I was thinking maybe we could actually just look up and check if the provided stack actually exists in spacelift instead of just returning the provided name?

	if cliCtx.IsSet(flagStackID.Name) {
		return cliCtx.String(flagStackID.Name), nil
	}

Would you mind look in to that and seeing if that actually works?

@tomasmik tomasmik self-requested a review September 28, 2023 06:49
@mwasilew2 mwasilew2 force-pushed the CU-862k09kgc_Add-suggestions-when-spacectl-does-not-find-an-entity_Michal-Wasilewski branch from 08fcc06 to 86a86c3 Compare September 29, 2023 07:44
@mwasilew2 mwasilew2 marked this pull request as draft September 29, 2023 08:23
@mwasilew2
Copy link
Contributor Author

We have this function called getStackID which is called every time you do anything with a command which interacts with stacks: https://github.com/spacelift-io/spacectl/blob/main/internal/cmd/stack/stack_selector.go#L19

Because this is called every time we parse the provided --id I was thinking maybe we could actually just look up and check if the provided stack actually exists in spacelift instead of just returning the provided name?

	if cliCtx.IsSet(flagStackID.Name) {
		return cliCtx.String(flagStackID.Name), nil
	}

Would you mind look in to that and seeing if that actually works?

You're right, it makes more sense to check for stack presence when we're extracting the stack id. The additional benefit of this is that this function is used in other places so we get nice error handling in those places as well.

@tomasmik let me know what you think of this approach

internal/cmd/stack/stack_selector.go Outdated Show resolved Hide resolved
internal/cmd/stack/stack_selector.go Outdated Show resolved Hide resolved
internal/cmd/stack/stack_selector.go Outdated Show resolved Hide resolved
internal/cmd/stack/stack_selector.go Outdated Show resolved Hide resolved
internal/cmd/stack/stack_selector.go Outdated Show resolved Hide resolved
Signed-off-by: Michal Wasilewski <[email protected]>
Signed-off-by: Michal Wasilewski <[email protected]>
Signed-off-by: Michal Wasilewski <[email protected]>
Signed-off-by: Michal Wasilewski <[email protected]>
@mwasilew2 mwasilew2 marked this pull request as ready for review September 29, 2023 09:47
Copy link
Contributor

@tomasmik tomasmik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing

@mwasilew2 mwasilew2 merged commit 1acca37 into main Sep 29, 2023
9 checks passed
@mwasilew2 mwasilew2 deleted the CU-862k09kgc_Add-suggestions-when-spacectl-does-not-find-an-entity_Michal-Wasilewski branch September 29, 2023 09:50
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

Successfully merging this pull request may close these issues.

3 participants