-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Record
can't parse (at least some) unknown
types
#204
Comments
This alternative change also works: diff --git a/atrium-api/src/types.rs b/atrium-api/src/types.rs
index 73d1d2b..4c04387 100644
--- a/atrium-api/src/types.rs
+++ b/atrium-api/src/types.rs
@@ -131,8 +131,8 @@ pub enum Union<T> {
/// The data of variants represented by a map and include a `$type` field indicating the variant type.
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
pub struct UnknownData {
- #[serde(rename = "$type")]
- pub r#type: String,
+ // #[serde(rename = "$type")]
+ // pub r#type: String,
#[serde(flatten)]
pub data: Ipld,
} So the problem is that, for the returned data for these particular Lexicon records, there is no |
Aha, I think I see the problem:
By contrast,
So I think the fix is that here in codegen: atrium/lexicon/atrium-codegen/src/token_stream.rs Lines 565 to 572 in 75673d0
we need to use Ipld as the fallback for an unknown field type, instead of Record (which was picked in a5b7ab8). More specifically, we need to use a type that wraps Ipld and enforces the ATProto data model.
|
Thank you for reporting the issue! In the early stages of implementation, I wanted to treat only the parts that would be considered to have a record as If possible, I would like to be able to handle the type |
The sense I get from their current docs and issue comments is that for That doesn't really work well with the current
The "try to parse |
I tried to implement Basically, an object (with or without What do you think of this? |
I've merged #209, which inherited your #205 fix, to be able to handle |
For an
AtpAgent
authenticated to my account,returns:
The lexicon in question is:
In both cases, the
unknown
type ends up being a map.Record
looks like it is intended to support parsing data with"type": "unknown"
, but that parsing is failing:atrium/atrium-api/src/records.rs
Lines 3 to 8 in 75673d0
atrium/atrium-api/src/types.rs
Lines 131 to 138 in 75673d0
If I make the following change to bypass
Record
andUnknownData
, going straight toIpld
:then parsing works, and the
dbg!
instead returns:The text was updated successfully, but these errors were encountered: