geeksforsocialchange / PlaceCal

Bring your community together
https://placecal.org
GNU Affero General Public License v3.0
17 stars 8 forks source link

[Bug]: Graphql query on Partner with logo field crashes #1462

Closed ivan-kocienski-gfsc closed 2 years ago

ivan-kocienski-gfsc commented 2 years ago

Description

try to look up a partner using the GraphQL API requesting the logo field and PlaceCal 500s

Steps to reproduce

  1. Wrote small script to read graphql endpoint (this could be a gist or an attachment)
  2. Run query, print result

What you expected to happen

See partner's logo field populated.

Code used

require 'graphql/client'
require 'graphql/client/http'

ENDPOINT = 'https://admin.placecal-staging.org/api/v1/graphql'
# ENDPOINT = 'http://admin.lvh.me:3030/api/v1/graphql'

module PlaceCal

  HTTP = GraphQL::Client::HTTP.new(ENDPOINT)

  Schema = GraphQL::Client.load_schema(HTTP)

  Client = GraphQL::Client.new(schema: Schema, execute: HTTP)

  PartnerQuery = Client.parse <<-GRAPHQL
    query($id: ID!) {
      partner(id: $id) {
        id
        name
        description
        summary
        contact { email, telephone }
        url
        address { streetAddress, postalCode, addressRegion, geo { latitude, longitude } }
        areasServed { name abbreviatedName }
        logo
      } }
  GRAPHQL
end

def lookup_partner(id)
  result = PlaceCal::Client.query(PlaceCal::PartnerQuery, variables: { id: id })
  puts JSON.pretty_generate(result.to_h)
end

lookup_partner 153

What should happen

{
  "partner": {
    "id": "153",
    "name": "Name",
    "description": "",
    "summary": "",
    "contact": {
      "email": "info@example.com",
      "telephone": "0808 123 4567"
    },
    "url": "",
    "address": null,
    "areasServed": [
      {
        "name": "England",
        "abbreviatedName": "England"
      }
    ],
    "logo": "http://localhost:3030/uploads/partner/image/153/reddit-grumpy-cat-2.jpg"
  }
}

What happens

{
  "errors": [
    {
      "message": "500 Internal Server Error"
    }
  ]
}
erbridge commented 2 years ago

This still seems to give a 500 on staging for me. Needs further investigation.

ivan-kocienski-gfsc commented 2 years ago

I am going to look into this for all image URLs (and to verify that the dev, staging and prod servers are configured to generate full URLs properly

erbridge commented 2 years ago

When I tested this last week, I got the described 500 response. Running the same script again now with no changes gives me the full response. What changed in the gap? This is running the precise script verbatim from the issue description.

ivan-kocienski-gfsc commented 2 years ago

I just verified this on production with partner ID 196. Going to close this now. If there are any problems found please record the server you were calling to and the partner ID