lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

[Bug]: Missing inbox_url

Open hagarashi8 opened this issue 1 year ago • 5 comments

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

  1. Try to run example code for lemmy_api_common

Technical Details

thread 'main' panicked at 'called Result::unwrap()on anErrvalue: reqwest::Error { kind: Decode, source: Error("missing fieldinbox_url", line: 1, column: 800) }' , src/main.rs:15:58

Version

BE 0.18

Lemmy Instance URL

No response

hagarashi8 avatar Jun 23 '23 17:06 hagarashi8

api got changed. frankly, just live with it, the devs dont seem to care about it

bqv avatar Jun 24 '23 02:06 bqv

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.

hagarashi8 avatar Jun 24 '23 05:06 hagarashi8

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.

Bnyro avatar Jun 24 '23 10:06 Bnyro

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?

derivator avatar Jun 24 '23 17:06 derivator

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 Options, but I haven't given it a lot of thought.

derivator avatar Jun 24 '23 17:06 derivator

https://github.com/LemmyNet/lemmy/pull/3362 fixes this.

Nutomic avatar Jun 27 '23 10:06 Nutomic

Awesome, thank you for the fast reaction!

Bnyro avatar Jun 27 '23 10:06 Bnyro