Skip to content
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

bsky thread --json returns invalid JSON. #7

Closed
hyuki opened this issue Apr 25, 2023 · 2 comments
Closed

bsky thread --json returns invalid JSON. #7

hyuki opened this issue Apr 25, 2023 · 2 comments

Comments

@hyuki
Copy link

hyuki commented Apr 25, 2023

bsky thread --json at://did:... returns invalid JSON.

Example session is as follows (full session is on gist):

[~] $ go version
go version go1.19.5 darwin/arm64
[~] $ bsky version
No help topic for 'version'
[~] $ bsky -version
bsky version 0.0.31
[~] $ bsky post "This post is for reporting an issue."
at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua2zpthm42n
[~] $ bsky post -r at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua2zpthm42n "This is a reply."
at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua345boc52s
[~] $ bsky thread --json at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua2zpthm42n | jq
{
  "author": {
    ...
  },
  "cid": "bafyreie6ozkcr5sfhcocg34gv7s7ya6vs5os57bo34ih5yqz23xzrvh5gy",
  "indexedAt": "2023-04-25T22:00:12.006Z",
  "likeCount": 0,
  "record": {
    ...
  },
  "replyCount": 1,
  "repostCount": 0,
  "uri": "at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua2zpthm42n",
  "viewer": {}
}
{
  "$type": "app.bsky.feed.defs#threadViewPost",
  "post": {
    "author": {
      ...
    },
    "cid": "bafyreigjf6s3ipgju2irqszouncglj7rzndhtf2kknsxmzgd6qo62eojim",
    "indexedAt": "2023-04-25T22:01:33.191Z",
    "likeCount": 0,
    "record": {
      "$type": "app.bsky.feed.post",
      "createdAt": "2023-04-26T07:01:33+09:00",
      "reply": {
        "parent": {
          "cid": "bafyreie6ozkcr5sfhcocg34gv7s7ya6vs5os57bo34ih5yqz23xzrvh5gy",
          "uri": "at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua2zpthm42n"
        },
        "root": {
          "cid": "bafyreie6ozkcr5sfhcocg34gv7s7ya6vs5os57bo34ih5yqz23xzrvh5gy",
          "uri": "at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua2zpthm42n"
        }
      },
      "text": "This is a reply."
    },
    "replyCount": 0,
    "repostCount": 0,
    "uri": "at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3jua345boc52s",
    "viewer": {}
  }
}
[~] $

As you can see, bsky thread --json at://did:... returns { ... }{ ... }. It is invalid JSON.

@mattn mattn closed this as completed in cdff7fd Apr 25, 2023
@hyuki
Copy link
Author

hyuki commented Apr 26, 2023

It looks that bsky thread --json still produces invalid JSON as follows.

$ brew install jsonlint
$ git log --oneline | head -3
cdff7fd thread's JSON should be FeedDefs_ThreadViewPost.Post
50a4a68 bump up version to 0.0.31
f646d1b add -pattern and -reply
$ make all
$ ./bsky thread --json at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3ju6nl3mnvx22 | jq | jsonlint -c
line 142, col 1, found: '{' - expected: 'EOF', '}', ',', ']'.
$ ./bsky thread --json at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3ju6nl3mnvx22 | jsonlint -c
line 1, col 4034, found: '{' - expected: 'EOF', '}', ',', ']'.

@hyuki
Copy link
Author

hyuki commented Apr 26, 2023

I heard that bsky produces ndjson. The separator is "\n".
So current behaviour is valid as ndjson.
Each line is valid JSON as follows:

$ ./bsky thread --json at://did:plc:k762js3b44u4kppedx63ozsw/app.bsky.feed.post/3ju6nl3mnvx22 | head -1 | jsonlint -c
(No error, displays pretty-printed JSON (for first line of result)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant