Skip to content

Commit

Permalink
fix: fix the code 400 when not chart in harbor (#1891)
Browse files Browse the repository at this point in the history
Signed-off-by: harrisonliu5 <[email protected]>
  • Loading branch information
harrisonliu5 committed Oct 24, 2023
1 parent 77f2b2f commit 640e8ae
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
8 changes: 2 additions & 6 deletions server/controllers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,9 @@ const handleHarborProxy = async ctx => {
let isErrorRes = false

if (requestUrl === 'search') {
const { repository, project, chart } = res
const { repository, project } = res
// Check whether the response is the requirements
isErrorRes = !(
Array.isArray(repository) &&
Array.isArray(project) &&
Array.isArray(chart)
)
isErrorRes = !(Array.isArray(repository) && Array.isArray(project))
} else {
isErrorRes = !Array.isArray(res)
}
Expand Down
15 changes: 7 additions & 8 deletions server/libs/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const send_harbor_request = ({ path, params }) => {
const contentType = response.headers.get('content-type')

if (contentType && contentType.includes('json')) {
return response.json().then(res => {
response.json().then(res => {
if (res.errors) {
const errorMsg = res.errors[0]
? res.errors[0].message
Expand All @@ -123,7 +123,6 @@ const send_harbor_request = ({ path, params }) => {
resolve({ repository: [], project: [], chart: [] })
}
}

if (
response.ok &&
response.status >= 200 &&
Expand All @@ -138,13 +137,13 @@ const send_harbor_request = ({ path, params }) => {
statusText: response.statusText,
})
})
} else {
reject({
code: 400,
statusText: response.statusText,
message: 'bad request',
})
}

reject({
code: 400,
statusText: response.statusText,
message: 'bad request',
})
})
.catch(err => {
reject(err)
Expand Down

0 comments on commit 640e8ae

Please sign in to comment.