Skip to content

Commit

Permalink
fix(controller): 500 when get deleted project by name (#3123)
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui authored Jan 11, 2024
1 parent 443bfcd commit cd671cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import ai.starwhale.mlops.domain.user.bo.Role;
import ai.starwhale.mlops.domain.user.bo.User;
import ai.starwhale.mlops.exception.StarwhaleException;
import ai.starwhale.mlops.exception.SwNotFoundException;
import ai.starwhale.mlops.exception.SwValidationException;
import io.jsonwebtoken.Claims;
import java.io.IOException;
Expand Down Expand Up @@ -90,7 +91,14 @@ protected void doFilterInternal(
header = httpServletRequest.getParameter(AUTH_HEADER);
}

var projects = getProjects(httpServletRequest);
Set<Project> projects;
try {
projects = getProjects(httpServletRequest);
} catch (SwNotFoundException e) {
error(httpServletResponse, HttpStatus.NOT_FOUND.value(), Code.validationException, e.getMessage());
return;
}

if (!verifyProjectsExist(httpServletRequest, httpServletResponse, projects)) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,18 @@ public interface ProjectMapper {
String getReadme(@Param("id") Long id);

@Select("select " + COLUMNS + " from project_info"
+ " where project_name = #{projectName}"
+ " and is_deleted = 0")
+ " where project_name = #{projectName}")
List<ProjectEntity> findByName(@Param("projectName") String projectName);

@Select("select " + COLUMNS + " from project_info"
+ " where project_name = #{projectName}"
+ " and owner_id = #{ownerId}"
+ " and is_deleted = 0")
+ " and owner_id = #{ownerId}")
ProjectEntity findExistingByNameAndOwner(@NotNull @Param("projectName") String projectName,
@NotNull @Param("ownerId") Long ownerId);

@Select("select " + COLUMNS + " from project_info"
+ " where project_name = #{projectName}"
+ " and owner_id = (select id from user_info where user_name = #{ownerName})"
+ " and is_deleted = 0")
+ " and owner_id = (select id from user_info where user_name = #{ownerName})")
ProjectEntity findExistingByNameAndOwnerName(@NotNull @Param("projectName") String projectName,
@NotNull @Param("ownerName") String ownerName);

Expand Down

0 comments on commit cd671cb

Please sign in to comment.