lemmy
lemmy copied to clipboard
[Bug]: Missing inbox_url
Requirements
- [X] Is this a bug report? For questions or discussions use https://lemmy.ml/c/lemmy_support
- [X] Did you check to see if this issue already exists?
- [X] Is this only a single bug? Do not put multiple bugs in one issue.
- [X] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
Summary
Not sure if it fits there, but i'm currently having trouble with lemmy_api_common, looks like it tries to find some inbox_url. I used example code. Looks like it happens only with BE 0.18.
Steps to Reproduce
- Try to run example code for lemmy_api_common
Technical Details
thread 'main' panicked at 'called
Result::unwrap()on an
Errvalue: reqwest::Error { kind: Decode, source: Error("missing field
inbox_url", line: 1, column: 800) }' , src/main.rs:15:58
Version
BE 0.18
Lemmy Instance URL
No response
api got changed. frankly, just live with it, the devs dont seem to care about it
api got changed. frankly, just live with it, the devs dont seem to care about it
Well, looks like it's not only thing wrong with 0.18, so guess he doesn't have enough time. If someone also was up to developing some Lemmy things with rust, there's convertor from json to rust structs for serde.
I got it working by the following changes: https://github.com/Bnyro/lemmy/commit/ff69cd151988fa4cff5a6f3789c5675a2e3257f8 and use my own fork for now (but I don't create a PR for that because I'm certain these changes would break something with the database, so the patch can only be used on client side).
Seems like #[serde(skip_serializing)]
brings the culprit in.
I don't really get why these fields are marked #[serde(skip_serializing)]
instead of #[serde(skip)]
. I guess it's because they're not optional on the server side, but I think that just doesn't work for anything that's used as part of an API response. Probably lemmy_api_common
could use some tests to ensure that responses can actually be deserialized?
Quick thought: perhaps a crate feature server_fields
could conditionally enable these fields only in the server implementation to avoid duplicating the structs or making things Option
s, but I haven't given it a lot of thought.
https://github.com/LemmyNet/lemmy/pull/3362 fixes this.
Awesome, thank you for the fast reaction!