zed icon indicating copy to clipboard operation
zed copied to clipboard

`zed expand <...> --json` does not match the expected schema

Open williamdclt opened this issue 3 years ago • 2 comments

The JSON output of zed expand returns something like:

{
  "expandedAt": {
    "token": "GgMKATY="
  },
  "treeRoot": {
    "expandedObject": {
      "objectId": "aae48b55-ad96-11eb-a562-06368a59bfb7",
      "objectType": "care_recipient"
    },
    "expandedRelation": "agency",
    "leaf": {}
  }
}

Whereas the API returns, for the same request:

{
  "expandedAt": {
    "token": "GgMKATY="
  },
  "treeRoot": {
    "treeType": {
      "oneofKind": "leaf",
      "leaf": {
        "subjects": []
      }
    },
    "expandedRelation": "agency",
    "expandedObject": {
      "objectType": "care_recipient",
      "objectId": "aae48b55-ad96-11eb-a562-06368a59bfb7"
    }
  }
}

In the zed response, we do not have the treeType attribute

williamdclt avatar May 06 '22 11:05 williamdclt

It also seems that for intermediate nodes, zed returns the operation attribute as something like "OPERATION_EXCLUSION" rather than 2 like the API

williamdclt avatar May 06 '22 13:05 williamdclt

We actually hadn't considered making the zed --json flag compatible with rest gateway, but it seems obvious in retrospect.

Looks like this is a difference between just calling protojson on the result vs how grpc gateway calls protojson.

I could see two ways of fixing this:

  1. making the --json flag actually perform a REST request instead of gRPC
  2. try make both sources generate the same output

I think I'm leaning towards the first option as just dumping the request with protojson was kinda a hack so we could use jq before we ever had an HTTP API.

jzelinskie avatar May 13 '22 21:05 jzelinskie