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

Documents with MediaType image/gif and image/webp unsupported #248

Closed
koehn opened this issue Feb 10, 2023 · 4 comments
Closed

Documents with MediaType image/gif and image/webp unsupported #248

koehn opened this issue Feb 10, 2023 · 4 comments

Comments

@koehn
Copy link
Contributor

koehn commented Feb 10, 2023

I’m getting this error when I try to hit my main page (just https://dogfood.social)

{
  "outcome": "ok",
  "scriptName": "pages-worker--844423-production",
  "exceptions": [],
  "logs": [
    {
      "message": [
        "-> GET https://dogfood.social/explore "
      ],
      "level": "log",
      "timestamp": 1676032920138
    },
    {
      "message": [
        "Error: unsupported media Document type: {\"type\":\"Document\",\"mediaType\":\"image/gif\",\"url\":\"https://cdn.mastodon.org.uk/media_attachments/files/109/839/605/089/052/923/original/a69b03718e5326e5.gif\",\"name\":\"Calvin wants to sled down dangerous slopes to sate his need for excitement.\",\"blurhash\":\"U6QT4M4n4n00_3Rjt7%Mof~q%MayIUD%t7fQ\",\"focalPoint\":[0,0],\"width\":900,\"height\":289}\n    at At2 (worker.mjs:8974:9)\n    at be2 (worker.mjs:8966:12)\n    at we2 (worker.mjs:9018:14)\n    at async Tt (worker.mjs:9068:16)\n    at async G2 (worker.mjs:9076:13)\n    at async worker.mjs:9411:26\n    at async xi.d [as __qrl] (worker.mjs:7991:16)\n    at async worker.mjs:10299:42\n    at async Promise.all (index 1)\n    at async worker.mjs:10298:7",
        null
      ],
      "level": "warn",
      "timestamp": 1676032920279
    },
    {
      "message": [
        "<- 500"
      ],
      "level": "log",
      "timestamp": 1676032920279
    }
  ],
  "eventTimestamp": 1676032920136,
  "event": {
    "request": {
      "url": "https://dogfood.social/explore",
      "method": "GET",
      "headers": {
        "accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
        "accept-encoding": "gzip",
        "cf-connecting-ip": "75.73.49.138",
        "cf-connecting-o2o": "1",
        "cf-ipcountry": "US",
        "cf-ray": "7974ec16caf813f8",
        "cf-visitor": "{\"scheme\":\"https\"}",
        "connection": "Keep-Alive",
        "host": "dogfood.social",
        "user-agent": "Uptime-Kuma/1.19.6",
        "x-forwarded-for": "75.73.49.138",
        "x-forwarded-proto": "https",
        "x-real-ip": "75.73.49.138"
      },
      "cf": {
        "longitude": "-93.44970",
        "httpProtocol": "HTTP/1.1",
        "tlsCipher": "AEAD-AES256-GCM-SHA384",
        "continent": "NA",
        "asn": 7922,
        "clientAcceptEncoding": "gzip",
        "country": "US",
        "tlsClientAuth": {
          "certIssuerDNLegacy": "",
          "certIssuerSKI": "",
          "certSubjectDNRFC2253": "",
          "certSubjectDNLegacy": "",
          "certFingerprintSHA256": "",
          "certNotBefore": "",
          "certSKI": "",
          "certSerial": "",
          "certIssuerDN": "",
          "certVerified": "NONE",
          "certNotAfter": "",
          "certSubjectDN": "",
          "certPresented": "0",
          "certRevoked": "0",
          "certIssuerSerial": "",
          "certIssuerDNRFC2253": "",
          "certFingerprintSHA1": ""
        },
        "tlsVersion": "TLSv1.3",
        "city": "Hopkins",
        "timezone": "America/Chicago",
        "requestPriority": "",
        "edgeRequestKeepAliveStatus": 1,
        "postalCode": "55343",
        "colo": "ORD",
        "latitude": "44.91430",
        "region": "Minnesota",
        "regionCode": "MN",
        "asOrganization": "Comcast Cable",
        "metroCode": "613",
        "pagesHostName": "wildebeest-koehn.pages.dev"
      }
    },
    "response": {
      "status": 500
    }
  },
  "id": 3
}
@xtuc
Copy link
Member

xtuc commented Feb 10, 2023

Also just saw on our test instance: unsupported image/webp

@xtuc xtuc changed the title Documents with MediaType image/gif unsupported Documents with MediaType image/gif and image/webp unsupported Feb 10, 2023
@xtuc
Copy link
Member

xtuc commented Feb 10, 2023

Quick fix is to add a condition in https://github.com/cloudflare/wildebeest/blob/main/backend/src/media/index.ts#L8-L16, pointing to the Image type. I'm currently working on making Images support better.

koehn pushed a commit to koehn/wildebeest that referenced this issue Feb 10, 2023
@koehn
Copy link
Contributor Author

koehn commented Feb 10, 2023

A better fix is:

const imageTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp']
export function fromObjectDocument(obj: Document): MediaAttachment {
	if (imageTypes.includes(obj.mediaType as string)) {
		return fromObjectImage(obj)
	} else if (obj.mediaType === 'video/mp4') {
		return fromObjectVideo(obj)
	} else {
		throw new Error(`unsupported media Document type: ${JSON.stringify(obj)}`)
	}
}

@xtuc
Copy link
Member

xtuc commented Feb 10, 2023

Do you mind sending a PR?

xtuc added a commit that referenced this issue Feb 10, 2023
@koehn koehn closed this as completed Feb 11, 2023
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

2 participants