Commit graph

2804 commits

Author SHA1 Message Date
Olivia Lee
05043f97a0
rename Error::Image to Error::GenerateThumbnail
The previous error was nonspecific and, because of the '#[from]'
annotation, could have been used accidentally for *any* errors from the
image crate.
2025-03-22 14:34:04 -07:00
Olivia Lee
ed7f7b2461
rename Error::Conflict to Error::AliasConflict
This is only used in one place.
2025-03-22 14:34:04 -07:00
Olivia Lee
a2628357fd
show source chain in error response message
Error messages in logs should generally be similar to the messages in
the response body now. There's a bit of a concern with the source chain
leaking sensitive information, but the errors that had a source were
generally already logging the second error in the chain in their own
Display impl, so if this is a problem it's unlikely to be a regression.
2025-03-22 14:34:04 -07:00
Olivia Lee
a3448b5c84
switch all error logs to using *_err macros 2025-03-22 14:34:04 -07:00
Olivia Lee
d28135f7ca
add helper macros to log error source chains
The specific thing that prompted this is that Error::Reqwest only logs
the Display impl of reqwest::Error, while the actual information you
need to determine what went wrong is usually buried deeper in the source
chain. This makes debugging federation networking issues super
frustrating.

Instead of just fixing this one case, let's just log the source chains
everywhere. What could go wrong?
2025-03-22 14:34:04 -07:00
Olivia Lee
5fca67054e
switch all tracing imports to observability::prelude 2025-03-22 14:34:02 -07:00
Olivia Lee
bc5f31b3a2
add observability prelude module
The reason to do a wildcard import of the prelude instead of something
like

    // src/observability/prelude.rs
    pub(crate) use tracing::*;

    // elsewhere
    use crate::observability::prelude as o;
    o::warn!("something");

is that we can't import traits like tracing::Instrument that way.

I'm generally not a fan of wildcard imports, but I think it can be okay
when it's a module in the same crate. There aren't really an backwards
compatibility hazards because it's your own code.
2025-03-22 14:19:18 -07:00
Olivia Lee
41c6fc8029
replace our DisplayWithSources with wee-woo
It's the same thing except with a nice extension trait.
2025-03-22 14:19:18 -07:00
Charles Hall
d6475eee6d
remove redundant condition 2025-03-21 16:48:56 -07:00
Charles Hall
799594cd1f
fix typo and update changelog
The MR number for the original MR was missing the leading `1`.
2025-03-21 16:28:11 -07:00
Charles Hall
218d75d573
update nixos module
Can't believe I forgot to do this...
2025-03-21 16:25:42 -07:00
Charles Hall
a04951541a
don't check canonicalized paths while sandboxed
Because the configured paths won't exist in the sandbox, so
canonicalization would fail.
2025-03-21 16:25:42 -07:00
Charles Hall
50583bc93e
reject overlapping non-canonical paths too
For example, if the database path is `/foo` and the media path is
`/foo/bar`, but `/foo/bar` is a symlink or hardlink to `/baz`, the
previous check would pass. The whole point of this check is to ensure
that the database and media data can't step on each other, so this check
is needed to deny that kind of situation as well.

It would probably be good to add a test for this behavior.
2025-03-21 16:25:31 -07:00
Charles Hall
b01b70fc20
reject overlapping media and database paths 2025-03-20 11:33:59 -07:00
Charles Hall
81a449d1d2
make database path a pathbuf
I'm guessing it wasn't like this already because of one of the admin
commands I deleted.
2025-03-20 11:33:59 -07:00
Charles Hall
5a5608e088
separate media and database paths
The primary motivation for this change is to support databases that
don't take a path, e.g. out of process databases.

This configuration structure leaves the door open for other media
storage mechanisms in the future, such as S3.

It's also structured to avoid `#[serde(flatten)]` so that we can use
`#[serde(deny_unknown_fields)]`.
2025-03-20 11:33:59 -07:00
Charles Hall
ae920fdbe8
make option name less redundant 2025-03-20 10:40:20 -07:00
Charles Hall
0a6d2b2731
make a media section in the config file 2025-03-20 10:40:20 -07:00
Charles Hall
f6b0a10e6e
implement _file in terms of _folder
what the heck lol
2025-03-20 10:40:16 -07:00
K900
fd2a0ac2ab nixos: allow Unix sockets
Because OF COURSE.
2025-03-18 18:18:09 +03:00
K900
ed67ae6418 nixos: fix systemd service type 2025-03-18 13:13:59 +00:00
Charles Hall
adb174d985
don't use file type flake inputs
Because they aren't supported by flake-compat and can't be without IFD.
2025-03-02 11:12:38 -08:00
Charles Hall
114e7ba577
allow supplying custom version extra info in nix 2025-03-02 10:57:13 -08:00
Charles Hall
e11e27bc0c
don't try to set version extra outside flakes
The two attributes being accessed here don't exist when calling though
flake-compat, so we need to handle that case by making the environment
variable unset if neither attribute exists.
2025-03-02 10:54:56 -08:00
Olivia Lee
57c79b1999
Fix native compilation on aarch64
Turns out fenix.packages.aarch64-linux.targets.x86_64-*.minimal.rustc
is an x86_64 compiler. The only component that you actually need to pull
from 'targets' for cross compilation is rust-std.

Because x86_64-unknown-linux-gnu is first in the target list, we were
getting x86 rustc and cargo binaries, making it impossible to compile
grapevine on an aarch64 host.

We were also missing aarch64-unknown-linux-gnu in the targets list,
which is used by the default package on a aarch64 host.
2025-03-02 01:20:51 -08:00
Lambda
65ec500d75 Enable useful new clippy lints
Picked from this filtered list:
https://rust-lang.github.io/rust-clippy/master/index.html?versions=gte%3A82%2Clte%3A84&levels=allow&groups=cargo%2Ccomplexity%2Ccorrectness%2Cnursery%2Cperf%2Crestriction%2Cstyle%2Csuspicious
2025-02-18 17:06:08 +00:00
Lambda
175a62007d Update MSRV to 1.84.0
And appease clippy (`__CARGO_FIX_YOLO=1 cargo clippy --fix` plus some
manual type shuffling).
2025-02-18 17:06:08 +00:00
Lambda
5616510727 Use UInt instead of u32 for max request size
Sometimes you just really want to upload a full disk image as media.
2025-02-18 16:48:47 +00:00
Lambda
99924e5779 Add admin commands to get and reset tracing filters 2025-02-17 17:41:14 +00:00
Lambda
5eab758bd2 Make tracing filter reload handles mutable
Makes the following diff nicer.
2025-02-17 17:40:55 +00:00
Olivia Lee
4cc390345a
don't markdownlint ignored files
I like to put a bunch of untracked stuff in a /scratch directory for
each project, and then puth /scratch in my global gitignore. There are
usually some markdown notes files in here that I don't care about style
for. The previous markdownlint invokation didn't respect the global
gitignore, making local 'engage' runs kinda useless due to false
positives from the scratch dir.
2025-01-23 13:04:59 -08:00
Olivia Lee
472f51c350
allow adding canonical aliases from remote servers
Like is mentioned in the comment, this isn't explicitly required by the
spec, but it's reasonable and what synapse does.
2025-01-23 09:20:10 -08:00
Olivia Lee
29d8fbaefa
only validate canonical aliases that are new
Previously we required every alias in a canonical alias event sent by a
client to be valid, and would only validate local aliases. This
prevented clients from adding/removing canonical aliases if there were
existing remote or invalid aliases.
2025-01-23 09:20:10 -08:00
Olivia Lee
50c1e77cd6
factor canonical alias event validation into a helper function
Not all the semantics from the spec quote in the doc comment are
implemented yet.
2025-01-23 09:20:10 -08:00
Olivia Lee
051221c0ab
validate schema of new canonical alias events sent by clients
Previously, we would only attempt to validate the aliases in the event
content if we were able to parse the event, and would silently allow it
otherwise.
2025-01-23 09:20:10 -08:00
Olivia Lee
c748c7c188
return M_BAD_ALIAS when trying to set non-existent canonical aliases
This is the error code named in the spec.
2025-01-20 16:59:01 -08:00
Charles Hall
8537c0e8ac
rearrange introduction
I think it's most important for people to read the "Chat with us", "Can
I use it?" and "Expectations management" sections, though I'm not sure
what the best ordering is. This is probably fine.
2024-12-13 17:00:37 -08:00
Charles Hall
5c4d7bbe37
rewrite "Can I use it?" section 2024-12-13 17:00:10 -08:00
Charles Hall
1808ad66f4
document supported targets
This is also a good spot to link to the pre-built binaries. And since I
did that, I can also remove the bit about not publishing binary builds
from the introduction section.
2024-12-13 16:59:13 -08:00
Charles Hall
28a4483c6e
move conduit migration to installing section 2024-12-13 16:59:13 -08:00
Charles Hall
f831dfd1f1
add "Installing" chapter to the book 2024-12-13 16:59:13 -08:00
Olivia Lee
491518d2f3
add changelog entry for M_NOT_YET_UPLOADED when media is missing in fs
The first half of this change happened in !55, but we never added a
changelog entry until now.
2024-12-13 01:21:14 -08:00
Olivia Lee
795ce42518
return M_NOT_YET_UPLOADED when backing files are missing for a thumbnail
This was done for fetching original media files in
c70cfd3d25, but the change for thumbnails
was missed.
2024-12-13 01:21:14 -08:00
Olivia Lee
f216112455
don't treat media file open errors other than NotFound as missing media
For example, we want to return M_UNKNOWN and propagate the error if
somebody set up their database directory permissions wrong.
2024-12-13 01:21:05 -08:00
Olivia Lee
67f0689d73
move media file read/write logic to a helper function 2024-12-13 01:18:46 -08:00
Charles Hall
1e050c8983
expose static binaries in gitlab artifacts again 2024-12-11 14:37:43 -08:00
Charles Hall
94c1a39437
add a style guide 2024-12-11 14:01:38 -08:00
Charles Hall
42adad330e
move security info to its own page
This makes it easier to find.

Also sort the maintainers list while I'm here.
2024-12-11 13:26:16 -08:00
Charles Hall
3a10e23d94
move matrix link to introduction page 2024-12-11 13:25:12 -08:00
Charles Hall
cf067dbeb1
move changelog section above contributing 2024-12-11 13:25:07 -08:00