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

bug: investigate possible regression with fallback path #31

Open
aosasona opened this issue Apr 11, 2024 · 5 comments
Open

bug: investigate possible regression with fallback path #31

aosasona opened this issue Apr 11, 2024 · 5 comments
Labels

Comments

@aosasona
Copy link
Owner

Latest deployment of my website does not seem to be falling back to 404.html as expected

@aosasona
Copy link
Owner Author

aosasona commented Apr 11, 2024

chimney/src/server.rs

Lines 281 to 287 in b0dc025

let file: File = match File::open(path).await.map_err(UnableToOpenFile) {
Ok(file) => file,
Err(error) => {
log_error!(format!("Failed to open file: {:?}", error));
return Ok(not_found());
}
};

This may be the culprit, we should checking for the fallback path when we load the config, and also before we send a plain 404

@aosasona
Copy link
Owner Author

Also here:

chimney/src/server.rs

Lines 271 to 276 in b0dc025

None => {
// The rewrite may be pointing to a redirect even if it is not a valid file, so we need to check
// for that here
handle_redirect!(server, target);
return Ok(not_found());
}

We are checking for rewrites and redirects but again, nothing about the fallback (which I am guessing has to do with the logic in the function to get a valid path

@aosasona
Copy link
Owner Author

I take it back, we seem to be doing the necessary checks at first glance but I will have a look again properly tomorrow

chimney/src/server.rs

Lines 176 to 183 in b0dc025

if !path.exists() {
if let Some(fallback) = self.config.fallback_document.clone() {
let fallback_path = PathBuf::from(&self.config.root_dir).join(fallback);
if fallback_path.exists() && fallback_path.is_file() {
path = fallback_path;
};
}
};

@aosasona
Copy link
Owner Author

Actually, this seems like it's happening specifically for /projects route

@aosasona
Copy link
Owner Author

aosasona commented Apr 13, 2024

Right! This is because the projects directory exists after building but it only contains images, so we are clearly not checking for the absence of that index.html and falling back somewhere. This is the file tree after building:

projects/
├── bazooka.png
├── chimney.png
├── cleep.png
├── crossbar.png
├── dotenv.png
├── falcon.png
├── hitlist.png
├── jenzo.png
├── jsorm.png
├── migrant.png
├── mirror.png
├── neat-http.png
├── phlo.png
├── phprouter.png
├── plunk.png
├── quiksnip.png
├── reda.png
├── scrawny.png
├── sidekyk.png
├── stripr.png
└── vanity.png

aosasona added a commit that referenced this issue Apr 19, 2024
This fixes #31 where it would render an empty 404 if the directory
exists but has no index file in it.
aosasona added a commit that referenced this issue May 1, 2024
This fixes #31 where it would render an empty 404 if the directory
exists but has no index file in it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant