gridonic / statamic-redirects

Manage URL redirects intuitively, discover and fix 404's automagically, improve your SEO dramatically
https://statamic.com/marketplace/addons/redirects
1 stars 1 forks source link

Failure to Parse YAML for log files causes error #8

Closed lachieh closed 3 years ago

lachieh commented 4 years ago

I have seen an issue where the log file got put into an unparseable state like this:

/blog/a-post-name: 2
/bl

This will throw an error when the addon attempts to add an entry to the log file.

Ideally, not being able to log a hit on a redirect should handle the exception silently and still redirect the user onto the correct location. I know there are some conditions around this, but it'd be better to at least move the broken file into a new location and create a new log than to fail loudly to the user.

mdouglasmorrison commented 3 years ago

Hi. We encountered this same issue yesterday. Is a resolution to this on the roadmap?

mdouglasmorrison commented 3 years ago

Hi. This is continuing to happen to us. Unless we hear otherwise we are going to assume that there will be no fix and our best course of action is to just to continue to delete the offending unparseable line when it appears.

wanze commented 3 years ago

Hi @lachieh and @mdouglasmorrison

Thanks for the report!

Ideally, not being able to log a hit on a redirect should handle the exception silently and still redirect the user onto the correct location

I agree with this: We should introduce a specific exception if we have a problem loading the logs, catch it and always perform the redirect. Not sure about starting a new log file, as this would be an "endless" problem.

It would be good to know why the YAML does not get written correctly in the first place. Looking at the code, the file should be written before the redirect exception is thrown, so the system should not be in the process of writing to the file while the redirect happens. Can you provide any information from your logs which indicates a problem there? Or think of anything else?

Cheers

wanze commented 3 years ago

This has been fixed with v1.5.0. Redirects are always executed when logging fails and and parse exceptions are logged to Statamic.