Skip to content

fix(vcs): honour the console URL scheme in installation callback defaults - #13599

Open
HarshMN2345 wants to merge 3 commits into
mainfrom
fix/vcs-callback-console-scheme
Open

fix(vcs): honour the console URL scheme in installation callback defaults#13599
HarshMN2345 wants to merge 3 commits into
mainfrom
fix/vcs-callback-console-scheme

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 10, 2026

Copy link
Copy Markdown
Member

What does this PR do?

Gates the VCS installation callbacks' default redirect on _APP_CONSOLE_URL_SCHEME, the same flag the commit statuses and the authorize-contributor link already use.

All three callbacks — the shared OAuth2 base, GitHub, and Origin — hardcoded their fallback to /console/project-{region}-{projectId}/settings/git-installations. On a root-scheme install that path does not exist, so the user landed on a dead page. Root scheme now falls back to /projects/{projectId}/settings.

The fallback only fires when state carries no success / failure URL. The console always signs those in, but an install started from the provider's side (installing the GitHub App straight from GitHub, for example) reaches the callback without them, which is exactly the path that was broken.

Cloud is a strict no-op: it sets no _APP_CONSOLE_URL_SCHEME, so its legacy branch is byte-identical to the string that was there before.

Test Plan

tests/e2e/Services/VCSGitea/VCSGiteaConsoleClientTest.php covers the fallback in two places: createInstallationHelper(redirects: false) and testCreateInstallationWithEmptyRedirects.

That suite runs under both schemes — server-ce's docker-compose.yml sets _APP_CONSOLE_URL_SCHEME=root, cloud leaves it at the default. Both CI stacks exec the suite inside the appwrite container, so the tests share its environment; defaultRedirectUrl() reads the flag and asserts the exact expected URL for whichever scheme is running, the same way this file already reads _APP_OPENSSL_KEY_V1 and _APP_REGION.

The second commit exists because the first one relaxed those assertions to substring checks on the project id, on the mistaken premise that a test could not see the flag. That relaxation was invariant along the one axis this PR changes — both URL shapes interpolate the project id — so inverting or deleting the ternary would have stayed green, and it dropped the region coverage cloud depends on. Now fixed.

Pint, PHPStan and Rector clean on all four changed files. Server-ce CI green on VCSGitea and VCSGitHub.

Related PRs and Issues

Follow-up to ea34e44, which moved the commit statuses and the authorize-contributor link onto this flag but left the callbacks behind.

Note for review: the new console has no settings/git-installations route, so /projects/{projectId}/settings is the closest existing target. Happy to change it if a dedicated page is planned.

…ults

The commit statuses and the authorize-contributor link were gated on
_APP_CONSOLE_URL_SCHEME, but the installation callbacks were not: when
state carries no success or failure URL, all three providers fell back to
/console/project-{region}-{id}/settings/git-installations. On a root-scheme
install that path does not exist, so an install started from the provider's
side landed on a dead page.

Build the fallback from the same flag, pointing root-scheme installs at the
project settings page.

The Gitea suite runs against both schemes -- server-ce sets root, cloud
leaves the default -- so the two assertions on the fallback now check that
it targets the project rather than pinning one scheme's path.
@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The production changes appear safe to merge, with only a non-blocking test-quality concern remaining in the existing review thread.

Fix All in Claude CodeFindings

  1. P2 Fallback regression goes undetected
Fix with agent prompt
### Issue 1
tests/e2e/Services/VCSGitea/VCSGiteaConsoleClientTest.php:undefined-322
This assertion only requires the redirect to contain the project ID. The previous broken `/console/project-{region}-{projectId}/...` URL satisfies that condition even under the root scheme. The failure-path checks at lines 541–542 have the same problem because the old URL also contains `?error=`. Reverting the production fix would therefore leave both tests green. Add an observable scheme-specific check, such as validating the redirect in an environment with a known console scheme, without duplicating the production configuration branch in the test.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

  • Root-scheme callbacks redirect to /projects/{projectId}/settings.
  • Legacy installations retain the existing region-specific git-installations URL.
  • The jobs worker receives the console domain, protocol, and URL-scheme settings.
  • VCS Gitea tests now assert exact fallback redirects, although the expectation remains coupled to the production configuration branch.

Reviews (3) · Last reviewed commit: "fix(compose): give the jobs worker the c..."

} else {
// Nothing was signed into state, so the callback falls back to its own
// console URL, whose shape follows _APP_CONSOLE_URL_SCHEME.
$this->assertStringContainsString($projectId, $location);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Fallback regression goes undetected

This assertion only requires the redirect to contain the project ID. The previous broken /console/project-{region}-{projectId}/... URL satisfies that condition even under the root scheme. The failure-path checks at lines 541–542 have the same problem because the old URL also contains ?error=. Reverting the production fix would therefore leave both tests green. Add an observable scheme-specific check, such as validating the redirect in an environment with a known console scheme, without duplicating the production configuration branch in the test.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/VCSGitea/VCSGiteaConsoleClientTest.php
Line: 322

Comment:
**Fallback regression goes undetected**

This assertion only requires the redirect to contain the project ID. The previous broken `/console/project-{region}-{projectId}/...` URL satisfies that condition even under the root scheme. The failure-path checks at lines 541–542 have the same problem because the old URL also contains `?error=`. Reverting the production fix would therefore leave both tests green. Add an observable scheme-specific check, such as validating the redirect in an environment with a known console scheme, without duplicating the production configuration branch in the test.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Fix in Claude Code Fix in Codex

@github-actions

github-actions Bot commented Sep 10, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/vcs-callback-console-scheme (after).

Metric Before After Change
🚀 Requests/sec 204.77 205.97 +0.6%
⏱️ Latency P50 84.56 ms 83.16 ms -1.6%
⏱️ Latency P95 202.89 ms 200.81 ms -1%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 83.16 200.81 12,825 205.97 -2.08
Account 171.83 311.26 675 11.22 -2.6
TablesDB 80.4 152.13 6,975 113.83 +2.55
Storage 76.52 167.54 3,375 57.12 +2.18
Functions 125.13 248.22 1,800 31.18 -6.1

Top API waits (after)

API request Max wait (ms)
account.name.update 506.74
functions.create 494.41
functions.variables.update 451.02
functions.delete 382.28
account.prefs.update 375.64

The previous commit relaxed these two assertions on the premise that a test
cannot see _APP_CONSOLE_URL_SCHEME. That premise was wrong: both CI stacks
exec the suite inside the appwrite container, and this file already reads
_APP_OPENSSL_KEY_V1, _APP_REGION and _APP_VCS_GITEA_ENDPOINT from that
environment.

Substring checks on the project id were invariant along the one axis the fix
changes -- both URL shapes interpolate the id -- so inverting or deleting the
ternary stayed green. Read the flag and assert the exact URL for whichever
scheme is running, which also restores the region coverage cloud relies on.
bin/worker-jobs reaches GitAction::run() through Functions/Workers/Jobs.php,
so it writes the commit-status target URLs and the PR comment's deployment
links. Its service was the one Git-linking container never given
_APP_CONSOLE_URL_SCHEME, _APP_CONSOLE_DOMAIN, _APP_DOMAIN or
_APP_OPTIONS_FORCE_HTTPS: the flag was added to appwrite, appwrite-worker,
appwrite-worker-webhooks and appwrite-worker-builds and this service, which
already existed, was skipped.

On a --profile separate stack every link it wrote fell back to the legacy
console paths, which the root-scheme console does not serve.
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.

1 participant