Skip to content

Commit

Permalink
update FS Handler
Browse files Browse the repository at this point in the history
Previously the FS handler would interpret a 500 status as a 404
in the adapter layer by checking if the response body contained
the text  or is the response status
was 500 and then throw an error code for 404.
  • Loading branch information
ChaiWithJai committed Nov 12, 2021
1 parent 7e8c154 commit 70acdb6
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
8 changes: 1 addition & 7 deletions ui/app/adapters/allocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,8 @@ async function handleFSResponse(response) {
} else {
const body = await response.text();

// TODO update this if/when endpoint returns 404 as expected
const statusIs500 = response.status === 500;
const bodyIncludes404Text = body.includes('no such file or directory');

const translatedCode = statusIs500 && bodyIncludes404Text ? 404 : response.status;

throw {
code: translatedCode,
code: response.status,
toString: () => body,
};
}
Expand Down
3 changes: 2 additions & 1 deletion ui/tests/acceptance/behaviors/fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,8 @@ export default function browseFilesystem({
...visitSegments({ allocation: this.allocation, task: this.task }),
path: '/what-is-this',
});
assert.equal(FS.error.title, 'Not Found', '500 is interpreted as 404');
assert.notEqual(FS.error.title, 'Not Found', '500 is not interpreted as 404');
assert.equal(FS.error.title, 'Server Error', '500 is not interpreted as 500');

await visit('/');

Expand Down

0 comments on commit 70acdb6

Please sign in to comment.