-
Notifications
You must be signed in to change notification settings - Fork 928
chore: create interface for pkgs to return codersdk errors #18719
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
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
b43bd8e
to
15a6ca1
Compare
f0dd768
to
a87678d
Compare
96c83c7
to
8d594a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I only have nits about naming and usage conventions, but these aren't blocking.
coderd/dynamicparameters/error.go
Outdated
Diagnostics hcl.Diagnostics | ||
KeyedDiagnostics map[string]hcl.Diagnostics |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: What's the difference between Diagnostics
and KeyedDiagnostics
?
When should you use one or the other?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will leave more comments!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a unified error interface and refactors workspace‐build and parameter validation errors to produce structured codersdk.Response
payloads.
- Introduce
CoderSDKError
interface andIsCoderSDKError
helper inhttperror/responserror.go
- Implement
Response()
onBuildError
and createDiagnosticError
for dynamic parameters - Update HTTP error writer and tests to use the new interface
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
coderd/wsbuilder/wsbuilder_test.go | Added TestWsbuildError to verify BuildError meets the new interface |
coderd/wsbuilder/wsbuilder.go | Implemented Response() on BuildError for structured responses |
coderd/httpapi/httperror/wsbuild.go | Simplified error handling to use IsCoderSDKError |
coderd/httpapi/httperror/responserror.go | Defined CoderSDKError interface and IsCoderSDKError function |
coderd/dynamicparameters/resolver.go | Swapped out ResolverError for calls to ParameterValidationError |
coderd/dynamicparameters/error.go | Added DiagnosticError type, constructors, and response logic |
Comments suppressed due to low confidence (3)
coderd/httpapi/httperror/responserror.go:9
- Add a doc comment above the
CoderSDKError
interface explaining its purpose and usage to improve discoverability.
type CoderSDKError interface {
coderd/dynamicparameters/error.go:13
- Add unit tests for
ParameterValidationError
(and the resultingDiagnosticError.Response
) to ensure validation error formatting remains correct.
func ParameterValidationError(diags hcl.Diagnostics) *DiagnosticError {
coderd/dynamicparameters/error.go:21
- Include doc comments for
TagValidationError
and theDiagnosticError
type to describe when and how these should be used.
func TagValidationError(diags hcl.Diagnostics) *DiagnosticError {
The dynamic parameter code lives in a package far removed from the httpapi and handlers. This interface allows it to create rich codersdk errors and pass them up to the
wsbuilder
error handling.This interface should probably be used in more places. I got tired of making custom error handling code for unique types.