psychonautwiki / bifrost

The PsychonautWiki API.
MIT License
51 stars 10 forks source link

Internal server error when querying 'shrooms', resulting in no units #29

Closed wjlafrance closed 4 years ago

wjlafrance commented 4 years ago

Hello! I'm encountering an issue through DoseBot where querying for 'shrooms' does not return units. I ran this query against the API playground:

{
        substances(query: "shrooms") {
            name
            addictionPotential
            class {
                chemical
                psychoactive
            }
            tolerance {
                full
                half
                zero
            }
            # routes of administration
            roas {
                name

                dose {
                    units
                    threshold
                    heavy
                    common { min max }
                    light { min max }
                    strong { min max }
                }

                duration {
                    afterglow { min max units }
                    comeup { min max units }
                    duration { min max units }
                    offset { min max units }
                    onset { min max units }
                    peak { min max units }
                    total { min max units }
                }

                bioavailability {
                    min max
                }
            }
        }
}

Receiving this response:

{
  "errors": [
    {
      "message": "Float cannot represent non numeric value: { max: 0.5, min: 0.25 }",
      "path": [
        "substances",
        0,
        "roas",
        0,
        "dose",
        "threshold"
      ],
      "code": "INTERNAL_SERVER_ERROR"
    }
  ],
  "data": {
    "substances": [
      {
        "name": "Psilocybin mushrooms",
        "addictionPotential": "not habit-forming with a low abuse potential",
        "class": {
          "chemical": [
            "Substituted_tryptamine"
          ],
          "psychoactive": null
        },
        "tolerance": {
          "full": "almost immediately after ingestion",
          "half": "3 days",
          "zero": "7 days"
        },
        "roas": [
          {
            "name": "oral",
            "dose": {
              "units": null,
              "threshold": null,
              "heavy": 5,
              "common": {
                "min": 1,
                "max": 2.5
              },
              "light": {
                "min": 0.5,
                "max": 1
              },
              "strong": {
                "min": 2.5,
                "max": 5
              }
            },
            "duration": null,
            "bioavailability": null
          }
        ]
      }
    ]
  }
}

I'm not sure if this is a bug in the API layer, or if it has to do with faulty data on PsychonautWiki, or is a problem with my query, but wanted to bring it to your attention. Also, the chemical class string looks to be non-transformed from it's database slug, and the psychoactive class is missing, but that may be another issue.

19h commented 4 years ago

Thanks, it's the same error as #15. I'll close this in favour of it.

19h commented 4 years ago

The cause of this bug is a misunderstanding by several users that there's an interval of "threshold." That's not a thing and Bifrost expects a singular threshold value. I'll fix it by fixing the articles. Thanks!

wjlafrance commented 4 years ago

Thanks for the quick response. Now when I run the same query the error is gone, however, the original problem remains. The dosage and psychoactive class are null, and the chemical class is not escaped.

{
  "data": {
    "substances": [
      {
        "name": "Psilocybin mushrooms",
        "addictionPotential": "not habit-forming with a low abuse potential",
        "class": {
          "chemical": [
            "Substituted_tryptamine"
          ],
          "psychoactive": null
        },
        "tolerance": {
          "full": "almost immediately after ingestion",
          "half": "3 days",
          "zero": "7 days"
        },
        "roas": [
          {
            "name": "oral",
            "dose": {
              "units": null,
              "threshold": 0.25,
              "heavy": 5,
              "common": {
                "min": 1,
                "max": 2.5
              },
              "light": {
                "min": 0.5,
                "max": 1
              },
              "strong": {
                "min": 2.5,
                "max": 5
              }
            },
            "duration": null,
            "bioavailability": null
          }
        ]
      }
    ]
  }
}

Since there are no API errors, is it just that the dosage unit and psychoactive class are missing from the data? I see the psilocybin mushrooms page is different from most other substances.

wjlafrance commented 4 years ago

Hi @19h, the original bug reported here is still not fixed. Would you mind reopening this ticket? image

19h commented 4 years ago

That's unrelated to the API and a data-level problem. The mushroom article is rather unusual to begin with as it's not a substance article. I'll amend some of the missing data.