sugyan / atrium

Rust libraries for Bluesky's AT Protocol services.
MIT License
188 stars 20 forks source link

Error on atrium-cli get-timeline #137

Closed Sanhajio closed 8 months ago

Sanhajio commented 8 months ago

Hello I started running atrium-cli; and came accross this error:

    (base) 22:27:12 ➜  rbsky git:(main) ✗ cargo install atrium-cli
    (base) 22:24:05 ➜  rbsky git:(main) ✗ atrium-cli --version
    atrium-cli 0.1.5

    (base) 22:25:55 ➜  rbsky git:(main) ✗ atrium-cli get-timeline
    Error: serde_json error: missing field `sig` at line 1 column 3311

    Caused by:
        missing field `sig` at line 1 column 3311
Sanhajio commented 8 months ago

It is weird, I generated the @atproto/lexicon@0.3.3 with:

cd lexicon && cargo run -p lexgen -- --lexdir $HOME/.ghq/github.com/bluesky-social/atproto/lexicons

And I still got the error.

    "label": {
      "type": "object",
      "description": "Metadata tag on an atproto resource (eg, repo or record).",
      "required": ["src", "uri", "val", "cts"],
      "properties": {
        "ver": {
          "type": "integer",
          "description": "The AT Protocol version of the label object."
        },
        "src": {
          "type": "string",
          "format": "did",
          "description": "DID of the actor who created this label."
        },
        "uri": {
          "type": "string",
          "format": "uri",
          "description": "AT URI of the record, repository (account), or other resource that this label applies to."
        },
        "cid": {
          "type": "string",
          "format": "cid",
          "description": "Optionally, CID specifying the specific version of 'uri' resource this label applies to."
        },
        "val": {
          "type": "string",
          "maxLength": 128,
          "description": "The short string name of the value or type of this label."
        },
        "neg": {
          "type": "boolean",
          "description": "If true, this is a negation label, overwriting a previous label."
        },
        "cts": {
          "type": "string",
          "format": "datetime",
          "description": "Timestamp when this label was created."
        },
        "exp": {
          "type": "string",
          "format": "datetime",
          "description": "Timestamp at which this label expires (no longer applies)."
        },
        "sig": {
          "type": "bytes",
          "description": "Signature of dag-cbor encoded label."
        }
      }
    },

But I don't get an error when I get a [#serde(default)]

#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct Label {
    ///Optionally, CID specifying the specific version of 'uri' resource this label applies to.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub cid: Option<crate::types::string::Cid>,
    ///Timestamp when this label was created.
    pub cts: crate::types::string::Datetime,
    ///Timestamp at which this label expires (no longer applies).
    #[serde(skip_serializing_if = "Option::is_none")]
    pub exp: Option<crate::types::string::Datetime>,
    ///If true, this is a negation label, overwriting a previous label.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub neg: Option<bool>,
    ///Signature of dag-cbor encoded label.
    #[serde(default)]
    #[serde(with = "serde_bytes")]
    #[serde(skip_serializing_if = "Option::is_none")]
    pub sig: Option<Vec<u8>>,
    ///DID of the actor who created this label.
    pub src: crate::types::string::Did,
    ///AT URI of the record, repository (account), or other resource that this label applies to.
    pub uri: String,
    ///The short string name of the value or type of this label.
    pub val: String,
    ///The AT Protocol version of the label object.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub ver: Option<i64>,
}
sugyan commented 8 months ago

atrium-cli v0.1.6 is now available and this problem is no longer reproduced as far as I have tried on my account. @Sanhajio Thanks for your contribution!