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

fix(controller): 500 when get deleted project by name #3123

Merged
merged 1 commit into from
Jan 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading