Skip to content

fix: treat a redirect with a Location header as webAuth - #1983

Open
HarshMN2345 wants to merge 2 commits into
mainfrom
fix/webauth-location-header
Open

HarshMN2345 wants to merge 2 commits into
mainfrom
fix/webauth-location-header

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Prerequisite for appwrite/appwrite#14192 (fixes appwrite/appwrite#14155).

What happens

appwrite/appwrite#14192 changes how the server spec declares its redirects. createOAuth2Session, createOAuth2Token and the VCS installation authorize routes now return:

"301": {
  "description": "Redirect",
  "headers": {
    "Location": { "description": "URL to redirect the client to.", "schema": { "type": "string", "format": "uri" } }
  }
}

instead of a 301 with a text/html binary body. getMethodType only recognised the old shape, so on the new spec both OAuth2 methods come back as false instead of webAuth. Client SDKs would call them as plain API requests instead of opening the browser.

Fix

A 3xx response that declares a Location header (case-insensitive, per OpenAPI) is webAuth. The binary-body check stays, so specs from servers without appwrite/appwrite#14192 keep working.

Verification

Both specs generated with php app/cli.php specs from appwrite main and from the #14192 branch:

Spec webAuth location upload graphql none
main, generator main 2 12 2 2 141
#14192, generator main 0 12 2 2 143
#14192, this branch 2 12 2 2 141

Web, Flutter, Android and React Native generated from the #14192 spec with this branch are byte-identical to the same SDKs generated from the main spec. Apple differs only in the unused accept header inside the two webAuth methods (text/html → application/json); those methods open the URL in WebAuthComponent and never send it.

testRedirectWithLocationIsWebAuth generates Web from a 301 with a lowercase location header and asserts the browser redirect, then asserts the legacy binary-body document generates the same files. It fails without the Language.php change.

tests/resources/spec-openapi3.json is unchanged: generalRedirect (301, no Location) stays a plain call and generalOauth2 stays webAuth. phpcs, rector --dry-run and the Generation suite pass.

Appwrite now declares its OAuth2 and VCS installation redirects as a 3xx
with a Location header and no body. getMethodType only recognised the old
shape, a 3xx with a binary body, so those methods fell back to plain API
calls. The binary-body check stays for specs from older servers.
@ghost

ghost commented Oct 7, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The added test exercises the new classification branch and preserves coverage of the legacy behavior; no new defects were found.

The pull request classifies redirect responses with a case-insensitive Location header as webAuth, retaining the binary-body fallback for older specs. It also adds a Web generation regression test that checks browser navigation output and equivalence with the legacy response shape.

Latest changes: The newest commit adds a generation test for a bodyless redirect with a lowercase location header and compares its generated SDK with the legacy binary-body redirect.

Verdict New comments Fixed Still open
✅ Approved 0 1 0
📂 Walkthrough · 2
File Change
src/SDK/Language.php Recognizes redirect responses declaring a Location header as webAuth.
tests/generation/GenerationTest.php Checks browser-navigation generation for header-only redirects and equivalence with legacy binary redirects.
✅ Fixed since the last review · 1
  • Add regression coverage for header-only OAuth redirects · src/SDK/Language.php:161

Reviewed the commits since a4c39c0 · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread src/SDK/Language.php Resolved

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

HarshMN2345 added a commit to appwrite/appwrite that referenced this pull request Oct 7, 2026
This reverts commit b9d46a7.

Redirects drop the body as #14155 requires. The generator that reads the
Location header ships through appwrite/sdk-generator#1983 and is bumped
on this branch.
cursor Bot pushed a commit to appwrite/appwrite that referenced this pull request Oct 7, 2026
sdk-generator 5.0.1 only treats a 3xx binary body as webAuth. Lock the
generator to appwrite/sdk-generator#1983 (e0bf097), which also accepts a
Location header, and stop emitting that body on 301, 302 and 308.
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

Successfully merging this pull request may close these issues.

Declare the Location header on OAuth2 redirect responses in the OpenAPI spec

1 participant