Skip to content

Comments

feat: consistent API errors#48

Merged
jason-lynch merged 1 commit intomainfrom
feat/PLAT-86/consistent-api-errors
Jun 13, 2025
Merged

feat: consistent API errors#48
jason-lynch merged 1 commit intomainfrom
feat/PLAT-86/consistent-api-errors

Conversation

@jason-lynch
Copy link
Member

@jason-lynch jason-lynch commented Jun 12, 2025

Adds an APIError type to our API spec and modifies our error handling code to return the new error type.

In this commit, requests to nonexistent routes will still return the generic Goa error type. This will change in a subsequent commit.

PLAT-86

@jason-lynch jason-lynch force-pushed the feat/PLAT-86/consistent-api-errors branch from 1af8911 to d3f2f7e Compare June 12, 2025 20:58
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/rename-inspect-endpoints branch from fa9a8f9 to 670f972 Compare June 12, 2025 21:07
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/consistent-api-errors branch 3 times, most recently from 1f9b253 to 8d0cd4d Compare June 12, 2025 21:16
@jason-lynch jason-lynch requested review from mmols and tsivaprasad June 12, 2025 21:41
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/rename-inspect-endpoints branch from 670f972 to 1c3be21 Compare June 12, 2025 21:53
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/consistent-api-errors branch from 8d0cd4d to 70afbc3 Compare June 12, 2025 21:53
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/rename-inspect-endpoints branch from 1c3be21 to 1e7a582 Compare June 13, 2025 11:31
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/consistent-api-errors branch from 70afbc3 to 9abe765 Compare June 13, 2025 11:31
return nil, fmt.Errorf("%w: %s", ErrNodeNotInDBSpec, name)
}

func (s *Spec) ValidateNodeNames(names ...string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

We can return early if names count is 0 ?

Copy link
Member Author

Choose a reason for hiding this comment

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

I appreciate that you're looking out for performance, but I don't think these types of micro-optimizations are all that helpful. The way that our business rules work, this should never be called with an empty list of names. In the off-chance that we change those rules so that it does become possible, the impact on overall performance is negligible. If an empty list would produce an error condition, I would feel differently, but in this case the function would still perform as expected.

Base automatically changed from feat/PLAT-86/rename-inspect-endpoints to main June 13, 2025 15:18
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/consistent-api-errors branch from 9abe765 to f3cc418 Compare June 13, 2025 17:15
Adds an `APIError` type to our API spec and modifies our error handling
code to return the new error type.

In this commit, requests to nonexistent routes will still return the
generic Goa error type. This will change in a subsequent commit.

PLAT-86
@jason-lynch jason-lynch force-pushed the feat/PLAT-86/consistent-api-errors branch from f3cc418 to 692fb66 Compare June 13, 2025 17:17
@jason-lynch jason-lynch requested a review from tsivaprasad June 13, 2025 17:24
@jason-lynch jason-lynch merged commit 3327ff7 into main Jun 13, 2025
2 checks passed
@jason-lynch jason-lynch deleted the feat/PLAT-86/consistent-api-errors branch June 13, 2025 18:20
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.

2 participants