-
Notifications
You must be signed in to change notification settings - Fork 2
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(5xx): should return 4xx when file not found #1291
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -319,7 +319,7 @@ export default class GitFileSystemService { | |
repoName: string, | ||
filePath: string, | ||
isStaging: boolean | ||
): ResultAsync<string, GitFileSystemError> { | ||
): ResultAsync<string, GitFileSystemError | NotFoundError> { | ||
const efsVolPath = isStaging | ||
? EFS_VOL_PATH_STAGING | ||
: EFS_VOL_PATH_STAGING_LITE | ||
|
@@ -333,6 +333,14 @@ export default class GitFileSystemService { | |
) | ||
|
||
if (error instanceof GitError) { | ||
// NOTE: While some path can be potentially normalised by Git (eg. images//path.png), | ||
// it is not guaranteed to exist in HEAD. We simply return a not found error in this case. | ||
if ( | ||
error.message.includes("fatal: path") && | ||
error.message.includes("exists on disk, but not in 'HEAD'") | ||
Comment on lines
+339
to
+340
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not a blocker for now, because we can raise a PR to improve this + bug is fixed here but i wonder if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. seems like best effort, since this is directly reliant on the error message that git returns us |
||
) { | ||
return new NotFoundError("File/Directory does not exist") | ||
} | ||
return new GitFileSystemError("Unable to determine Git blob hash") | ||
} | ||
|
||
|
@@ -1121,7 +1129,11 @@ export default class GitFileSystemService { | |
) | ||
) | ||
.andThen((directoryContents) => { | ||
const resultAsyncs = directoryContents.map((directoryItem) => { | ||
const IGNORED_FILES = [".git"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think the pattern we might wanna aim for here is to respect the filesystem's convention! in here, this means that hidden files/folders (prefixed by a `.) should be ignored rather than a specific instance. wwdyt? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm i rather keep this as .git since this actually is not the file system convention, but rather the .git system's convention. since they dont have a direct mapping, opting for the stricter check here. |
||
const filteredDirectoryContents = directoryContents.filter( | ||
(directoryItem) => !IGNORED_FILES.includes(directoryItem.name) | ||
) | ||
const resultAsyncs = filteredDirectoryContents.map((directoryItem) => { | ||
const isDirectory = directoryItem.isDirectory() | ||
const { name } = directoryItem | ||
const path = directoryPath === "" ? name : `${directoryPath}/${name}` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
would you know why the request even contains things like //filename?
are these actually broken links that cms tries to resolve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have a markdown editor, so there are possibility for typo + the logs suggest this has occurred at least once.
we dont debounce too, to this could occur while the user is typing the correct string.
yes, intuitively should be able to resolve them gracefully by 4xx rather than 5xx
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we add comments for this check here so that we don't lose context of when this error statements occur?