1
0
forked from wrenn/wrenn

Merge pull request 'bugfix: preserve agent gRPC status codes and map AlreadyExists to 409 Conflict' (#20) from bugfix/mkdir-already-exists-409 into dev

Reviewed-on: wrenn/wrenn#20
This commit is contained in:
2026-04-11 17:59:16 +00:00
2 changed files with 6 additions and 2 deletions

View File

@ -50,8 +50,12 @@ func agentErrToHTTP(err error) (int, string, string) {
return http.StatusNotFound, "not_found", err.Error() return http.StatusNotFound, "not_found", err.Error()
case connect.CodeInvalidArgument: case connect.CodeInvalidArgument:
return http.StatusBadRequest, "invalid_request", err.Error() return http.StatusBadRequest, "invalid_request", err.Error()
case connect.CodeFailedPrecondition: case connect.CodeFailedPrecondition, connect.CodeAlreadyExists:
return http.StatusConflict, "conflict", err.Error() return http.StatusConflict, "conflict", err.Error()
case connect.CodePermissionDenied:
return http.StatusForbidden, "forbidden", err.Error()
case connect.CodeUnimplemented:
return http.StatusNotImplemented, "agent_error", err.Error()
default: default:
return http.StatusBadGateway, "agent_error", err.Error() return http.StatusBadGateway, "agent_error", err.Error()
} }

View File

@ -290,7 +290,7 @@ func (s *Server) MakeDir(
resp, err := client.MakeDir(ctx, msg.Path) resp, err := client.MakeDir(ctx, msg.Path)
if err != nil { if err != nil {
return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("make dir: %w", err)) return nil, fmt.Errorf("make dir: %w", err)
} }
return connect.NewResponse(&pb.MakeDirResponse{ return connect.NewResponse(&pb.MakeDirResponse{