Page MenuHomeSoftware Heritage

graphql: object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>)
Closed, MigratedEdits Locked

Description

On https://graphql.staging.swh.network/

This query:

query {
  origin(url: "https://github.com/progval/Limnoria") {
    id
    visits(first: 10) {
      nodes {
        id
        visitId
        status(first: 2) {
          nodes {
            status
            snapshot {
              swhid
            }
          }
        }
      }
    }
  }
}

returns this:

{
  "data": {
    "origin": {
      "id": "fbc59d47d4cc806cfdae45afc0a77a9a3dd482a6",
      "visits": {
        "nodes": [
          {
            "id": "aHR0cHM6Ly9naXRodWIuY29tL3Byb2d2YWwvTGltbm9yaWEtMQ==",
            "visitId": 1,
            "status": {
              "nodes": [
                {
                  "status": "created",
                  "snapshot": null
                }
              ]
            }
          },
          {
            "id": "aHR0cHM6Ly9naXRodWIuY29tL3Byb2d2YWwvTGltbm9yaWEtMg==",
            "visitId": 2,
            "status": {
              "nodes": [
                {
                  "status": "created",
                  "snapshot": null
                },
                {
                  "status": "full",
                  "snapshot": {
                    "swhid": "swh:1:snp:d6a18550ce6a380b67cd44e7b6ed316a028598a2"
                  }
                }
              ]
            }
          },
          {
            "id": "aHR0cHM6Ly9naXRodWIuY29tL3Byb2d2YWwvTGltbm9yaWEtMw==",
            "visitId": 3,
            "status": {
              "nodes": [
                {
                  "status": "created",
                  "snapshot": null
                },
                {
                  "status": "full",
                  "snapshot": {
                    "swhid": "swh:1:snp:fee6a7f17524ce32b01bc6ce06943302e6c524fc"
                  }
                }
              ]
            }
          },
          {
            "id": "aHR0cHM6Ly9naXRodWIuY29tL3Byb2d2YWwvTGltbm9yaWEtNA==",
            "visitId": 4,
            "status": {
              "nodes": [
                {
                  "status": "created",
                  "snapshot": null
                },
                {
                  "status": "full",
                  "snapshot": {
                    "swhid": "swh:1:snp:fee6a7f17524ce32b01bc6ce06943302e6c524fc"
                  }
                }
              ]
            }
          }
        ]
      }
    }
  },
  "errors": [
    {
      "message": "object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>)",
      "locations": [
        {
          "line": 11,
          "column": 13
        }
      ],
      "path": [
        "origin",
        "visits",
        "nodes",
        0,
        "status",
        "nodes",
        0,
        "snapshot"
      ]
    },
    {
      "message": "object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>)",
      "locations": [
        {
          "line": 11,
          "column": 13
        }
      ],
      "path": [
        "origin",
        "visits",
        "nodes",
        1,
        "status",
        "nodes",
        0,
        "snapshot"
      ]
    },
    {
      "message": "object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>)",
      "locations": [
        {
          "line": 11,
          "column": 13
        }
      ],
      "path": [
        "origin",
        "visits",
        "nodes",
        2,
        "status",
        "nodes",
        0,
        "snapshot"
      ]
    },
    {
      "message": "object_id must be <class 'bytes'> (got None that is a <class 'NoneType'>)",
      "locations": [
        {
          "line": 11,
          "column": 13
        }
      ],
      "path": [
        "origin",
        "visits",
        "nodes",
        3,
        "status",
        "nodes",
        0,
        "snapshot"
      ]
    }
  ]
}

Event Timeline

vlorentz created this task.

This is a bit tricky to fix.
Snapshot is available only in a visit status with 'full' status. But there is only one visit-status object and it has a field snapshot.
Did a fix that returns a sensible error instead of a creepy one.

Maybe the correct fix is to add multiple types for visit-status (PartialStatus, FullStatus etc) and force the client to use query introspection.

anlambert added a subscriber: anlambert.

Snapshot is available only in a visit status with 'full' status.

FYI, a partial visit can also have a snapshot.