Skip to content

chore: remove dev keys - #13696

Merged
HarshMN2345 merged 8 commits into
mainfrom
chore/remove-dev-keys
Sep 16, 2026
Merged

HarshMN2345 merged 8 commits into
mainfrom
chore/remove-dev-keys

Conversation

@HarshMN2345

@HarshMN2345 HarshMN2345 commented Sep 15, 2026 •

Copy link
Copy Markdown
Member

What does this PR do?

Removes dev keys entirely. #12931 stopped new dev keys from being created (410), but existing keys were still accepted and still bypassed abuse limits, CSRF protection, and origin/redirect validation, including the OAuth2 success/failure URL checks.

  • Removes the dev key routes (create, list, get, update, delete), the DevKey model, the DevKeys query validator and the dev_key_gone error
  • Removes X-Appwrite-Dev-Key / ?devKey= handling from the HTTP and realtime request resources, along with the bypasses in shared/api.php, general.php and the OAuth2 redirect
  • Removes the devKeys.read / devKeys.write scopes, the CORS allowed header, the Project devKeys field and the DevKey spec security scheme
  • Removes the devKeys collection, the project devKeys attribute and the subQueryDevKeys filter. V25 deletes the attribute and collection on existing installs

Older migrations and Migrate.php still register subQueryDevKeys as a no-op filter: the stored project attribute references it, and documents cannot be decoded without it until V25 has dropped the attribute. Until migrate runs on an existing install, project reads fail with Filter "subQueryDevKeys" not found.

Test Plan

  • php -l and Pint on every changed file
  • E2E through CI

Related PRs and Issues

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

Remove the dev key routes, model, query validator, scopes, CORS header,
spec security scheme, and the request/realtime handling that let a dev
key bypass abuse limits, CSRF, and origin/redirect validation.

Drop the devKeys collection and project attribute from the platform
schema; V25 deletes both from existing installs.
'array' => false,
'filters' => ['subQueryKeys'],
],
[

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.

Lets note down to do migration on cloud to remove these too

"Access to create, update, and delete organization projects' API keys",
"category" => "Projects",
],
"devKeys.read" => [

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.

Also migration, to remove from existing keys and functions/sites

Comment thread app/config/roles.php
Comment on lines -97 to -98
'devKeys.read',
'devKeys.write',

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.

We might need cloud PR that removes these from ustom roles. maybe not, but lets check

);

Database::addFilter(
'subQueryDevKeys',

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.

Lets check cloud for this too, we might have some filters override that touch this filter key

@Meldiron Meldiron Sep 15, 2026 •

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.

Lets avoid changing existing migrations

@github-actions

github-actions Bot commented Sep 15, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → chore/remove-dev-keys (after).

Metric Before After Change
🚀 Requests/sec 217.46 206.88 ⚪ -4.9%
⏱️ Latency P50 79.91 ms 83.27 ms ⚪ +4.2%
⏱️ Latency P95 191.69 ms 203.18 ms 🔴 +6%
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.27 203.18 12,711 206.88 +11.5
Account 159.34 297.04 669 11.12 -0.71
TablesDB 79.3 149.67 6,913 114.09 +8.18
Storage 76.57 169.81 3,345 56.85 +5.86
Functions 125.86 280.69 1,784 30.99 +43.3

Top API waits (after)

API request Max wait (ms)
account.name.update 658.18
functions.variables.delete 564.29
functions.variables.create 558.59
functions.delete 437.26
account.prefs.update 426.17

$this->dbForProject->deleteCollection('devKeys');
} catch (Throwable $th) {
Console::warning("Failed to delete collection \"devKeys\": {$th->getMessage()}");
}

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.

I think we need to iterate api keys, functions and sites, to remove the scopes we removed

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.

Lets not touch historical filters, instead, add new one

@greptile-apps

greptile-apps Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 3/5

The PR is not yet safe to merge because V25 can still leave an existing empty legacy devKeys collection behind, and the explicit testing requirement is not satisfied.

Fix All in Claude CodeFindings

  1. P1 Empty Collection Survives Migration ▶
  2. P2 Security Removal Lacks Coverage ▶
Fix with agent prompt
### Issue 1
src/Appwrite/Migration/Version/V25.php:84-85
When the legacy `devKeys` collection exists but contains no documents, `isEmpty()` returns true and the migration skips `deleteCollection()`. Since earlier migrations create this collection even if it is never populated, an upgrade can complete while leaving the legacy schema behind. Delete the collection whenever it exists, regardless of its document count.

### Issue 2
tests/e2e/Services/Projects/ProjectsConsoleClientTest.php:undefined-6312
This removes the only dev-key endpoint test without replacing it with observable coverage. No test now shows that legacy header or query credentials cannot bypass abuse limits, CSRF, origin checks, or OAuth redirect validation. There is also no test showing that the removed routes are unavailable or that V25 removes existing dev-key schema and records. Add end-to-end tests for these externally visible outcomes rather than assertions that mirror configuration or source symbols.

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

This PR removes development-key authentication and its security bypasses, deletes the associated endpoints, models, scopes, schema, and response fields, and adds upgrade compatibility handling. Changes since the prior review also introduce substantial console URL, nightly release, execution storage, statistics scheduling, and worker updates.

  • Legacy dev-key credentials no longer bypass abuse, CSRF, origin, or OAuth redirect checks.
  • V25 removes the project attribute, legacy collection, and obsolete scopes.
  • Older response formats receive compatibility filtering for the removed project field.
  • Subsequent changes migrate generated links to _APP_CONSOLE_URL, move execution queries to schema-independent validators, and add nightly publishing and statistics scheduling behavior.
  • One newly added test violates the repository requirement to test observable behavior rather than internal implementation decisions.

Reviews (5) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..."

Comment thread src/Appwrite/Migration/Version/V25.php Resolved
$this->assertEquals(Exception::DEV_KEY_GONE, $response['body']['type']);
}

public function testProjectLabels(): void

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 Security Removal Lacks Coverage

This removes the only dev-key endpoint test without replacing it with observable coverage. No test now shows that legacy header or query credentials cannot bypass abuse limits, CSRF, origin checks, or OAuth redirect validation. There is also no test showing that the removed routes are unavailable or that V25 removes existing dev-key schema and records. Add end-to-end tests for these externally visible outcomes rather than assertions that mirror configuration or source symbols.

Prompt To Fix With AI
This is a comment left during a code review.
Path: tests/e2e/Services/Projects/ProjectsConsoleClientTest.php
Line: 6312

Comment:
**Security Removal Lacks Coverage**

This removes the only dev-key endpoint test without replacing it with observable coverage. No test now shows that legacy header or query credentials cannot bypass abuse limits, CSRF, origin checks, or OAuth redirect validation. There is also no test showing that the removed routes are unavailable or that V25 removes existing dev-key schema and records. Add end-to-end tests for these externally visible outcomes rather than assertions that mirror configuration or source symbols.

---

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

HarshMN2345 and others added 4 commits September 15, 2026 14:15
Historical migrations and response filters stay as released.
… failures

V25 removes devKeys.read and devKeys.write from key, function and site
scopes. The devKeys attribute and collection are deleted only when they
exist, and a failed delete now aborts the migration instead of logging a
warning, since project documents cannot be decoded while the attribute
remains.
….3.0

Add the V28 response filter, which returns an empty devKeys list on
projects for older response formats, and fill devKeys in the generated
SDK hydration test since the published PHP SDK still requires it.
Comment on lines +84 to +85
if (!$this->dbForProject->getCollection('devKeys')->isEmpty()) {
$this->dbForProject->deleteCollection('devKeys');

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.

P1 Empty Collection Survives Migration

When the legacy devKeys collection exists but contains no documents, isEmpty() returns true and the migration skips deleteCollection(). Since earlier migrations create this collection even if it is never populated, an upgrade can complete while leaving the legacy schema behind. Delete the collection whenever it exists, regardless of its document count.

Prompt To Fix With AI
This is a comment left during a code review.
Path: src/Appwrite/Migration/Version/V25.php
Line: 84-85

Comment:
**Empty Collection Survives Migration**

When the legacy `devKeys` collection exists but contains no documents, `isEmpty()` returns true and the migration skips `deleteCollection()`. Since earlier migrations create this collection even if it is never populated, an upgrade can complete while leaving the legacy schema behind. Delete the collection whenever it exists, regardless of its document count.

---

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

Fix in Claude Code Fix in Codex

Comment thread tests/unit/Utopia/ResponseTest.php Resolved
HarshMN2345 and others added 3 commits September 15, 2026 14:42
The SDK hydration test now builds the project response the way the server
does, running output() and then the V28 filter that older response formats
receive, instead of adding devKeys to the fixture by hand.
# Conflicts:
#	app/controllers/api/account.php
@HarshMN2345
HarshMN2345 merged commit d04542c into main Sep 16, 2026
47 checks passed
JadeCong pushed a commit to CloudEngineHub/appwrite that referenced this pull request Oct 9, 2026
Dev keys were removed from the API (appwrite#13696, appwrite-labs/cloud#5842) and this console never had a page for them, but the docs still taught the feature. Drop the dev keys page and its screenshots, the dev keys sections on the rate limits and partners API keys pages, the security card and nav entry, and the three dead console references to the retired scopes and legacy path segment. The old page URLs redirect to the rate limits page so inbound links keep resolving. Blog posts and changelog entries stay as dated history.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
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.

2 participants