matrix-org / dendrite

Dendrite is a second-generation Matrix homeserver written in Go!

Home Page:https://matrix-org.github.io/dendrite/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Wrong Content-Type for some JSON responses like 404's

morguldir opened this issue · comments

Reported-By: @roughnecks

Background information

  • dendrite.matrix.org
  • Dendrite version or git SHA: 0.13.6+87f028d
  • Client used (if applicable): Element Web >= 1.11.60

Description

  • What is the problem: Dendrite returns the wrong content type for 404 M_UNKNOWN, text/plain, for example for /_matrix/client/unstable/org.matrix.msc2965/auth_issuer
  • Who is affected: People using Dendrite with Element Web, or anyone else requiring json as the content type
  • How is this bug manifesting: Element tells you "your Element is misconfigured"
  • When did this first appear: Element Web 1.11.60, i suspect the return type hasn't been important before though

Steps to reproduce

  • go to app.element.io
  • set server to dendrite.matrix.org
  • observe the error

Headers

curl https://dendrite.matrix.org/_matrix/client/unstable/org.matrix.msc2965/auth_issuer -I
HTTP/2 404 
date: Sun, 07 Apr 2024 14:16:16 GMT
content-type: text/plain; charset=utf-8
content-length: 59
access-control-allow-headers: Origin, X-Requested-With, Content-Type, Accept, Authorization
access-control-allow-methods: GET, POST, PUT, DELETE, OPTIONS
access-control-allow-origin: *
strict-transport-security: max-age=15724800; includeSubDomains
cf-cache-status: DYNAMIC
server: cloudflare
cf-ray: 870aa26e0a396661-AMS

Explanation

the content is fine, but the Content-Type header must be application/json as per the spec: https://spec.matrix.org/v1.10/client-server-api/#api-standards

Servers must include a Content-Type header of application/json for all JSON responses.

- Michael (t3chguy) => https://matrix.to/#/!YTvKGNlinIzlkMTVRl:matrix.org/$Ccl7mmAOGI8KhBJ0BzOM63Wje1gcmh2IX6tAchUXXZ8?via=matrix.org&via=privacytools.io&via=mozilla.org

Thanks 👍