discourse/app
Ted Johansson aaec964547
DEV: Add both safe and unsafe Discourse.store.download methods (stable) (#21499)
### Background

Several call sites use `FileStore#download` (through `Discourse.store.download`). In some cases the author seems aware that the method can raise an error if the download fails, and in some cases not. Because of this we're seeing some of these exceptions bubble all the way up and getting logged in production. Although they are not really actionable at that point. Rather each call site needs to be considered to figure out how to handle them.

### What is this change?

This change accomplishes primarily two things.

Firstly it separates the method into a safe version which will handle errors by returning `nil`, and an unsafe version which will re-package upstream errors in a new `FileStore::DownloadError` class.

Secondly it updates the call sites which have been doing error handling downstream to use the new safe version.

For backwards compatibility, there's an interim situation and a desired end state.

**Interim:**

```
FileStore#download      → Old unsafe version. Will raise any error and show a deprecation warning.
FileStore#download!     → New unsafe version. Will raise FileStore::DownloadError.
FileStore#download_safe → New safe version.   Will return nil.
```

**Desired end-state:**

```
FileStore#download  → New safe version.   Will return nil.
FileStore#download! → New unsafe version. Will raise FileStore::DownloadError.
```

### What's next?

We need to do a quick audit of the call sites that are using the old unsafe version without any error handling, as well as check for call sites in plugins other repos. Follow-up PRs incoming.
2023-05-12 11:38:08 +08:00
..
assets SECURITY: Fix XSS in full name composer reply 2023-03-16 16:25:48 -06:00
controllers SECURITY: Ensure site setting being updated is a configurable site setting (#21132) 2023-04-18 14:32:21 +08:00
helpers DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
jobs DEV: Fix threading error when running jobs immediately in system tests (#19811) 2023-01-10 13:41:25 +08:00
mailers DEV: Apply syntax_tree formatting to app/* 2023-01-09 14:14:59 +00:00
models DEV: Add both safe and unsafe Discourse.store.download methods (stable) (#21499) 2023-05-12 11:38:08 +08:00
serializers FIX: Preload user sidebar attrs when ?enable_sidebar=1 (#19843) 2023-01-25 13:48:49 +02:00
services FIX: Do not add empty use/svg tags in ExcerptParser (#19969) 2023-01-25 13:48:49 +02:00
views UX: add btn-primary class on email confirm page (#19803) 2023-01-09 15:26:56 -05:00