Skip to content

test(scopes): read each catalog from its own file - #14229

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/scopes-test-own-catalog
Oct 7, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/scopes-test-own-catalog

Conversation

@ChiragAgg5k

@ChiragAgg5k ChiragAgg5k commented Oct 7, 2026 •

Copy link
Copy Markdown
Member

Summary

tests/unit/General/ScopesTest.php (#14206) compared Config::getParam('projectScopes' | 'organizationScopes' | 'accountScopes') against this repository's app/config/scopes/lock.json. Cloud runs the CE unit suite through its own bootstrap and registers its own, larger catalogs under the same keys. So once Cloud picks up #14206, the test fails on every Cloud-only scope (dedicatedDatabases.execute, organization.installations.read), as on appwrite-labs/cloud#6371. Cloud already locks its catalogs against its own lock.json in tests/unit/Config/ScopesTest.php.

The test now reads each catalog from app/config/scopes/<catalog>.php next to the lock, which is the file app/init/configs.php registers. That pairs this repository's scopes with this repository's lock no matter which app bootstraps the suite. The assertions are unchanged.

Tests

  • vendor/bin/phpunit tests/unit/General/ScopesTest.php: 6 tests, 224 assertions.
  • Still catches a removal: deleting project.write from app/config/scopes/project.php fails with "Scope 'project.write' was removed from the project scopes".
  • Under Cloud's bootstrap (--bootstrap app/init.php --configuration vendor/appwrite/server-ce/phpunit.xml, as Cloud's CE / Unit job runs it), with server-ce at current main:
    • Before: 2 failures, the same as Cloud CI.
    • After: 6 tests pass.
  • Pint and PHPStan pass.

Related: #13828

Cloud runs this suite with its own catalogs registered under the same
keys, so pairing the registry with this repository's lock.json failed on
every Cloud-only scope. Cloud locks its catalogs itself; this test now
checks app/config/scopes/*.php against the lock next to them.
@luxor-code-review

luxor-code-review Bot commented Oct 7, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This single-file change makes the scope contract lock validate the shipped catalog files directly rather than the merged runtime registry. All review lenses came back clean: the catalogs are associative arrays keyed exactly as lock.json expects, the assertion loops match that shape, and computeScopes was already outside the lock test before this change.

Files Change
tests/unit/General/ScopesTest.php Reads app/config/scopes/{project,organization,account}.php via include with local $scope/$locked helpers instead of pulling catalogs from Config::getParam; contract assertions are behavior-preserving.

The high-confidence candidates raised by the domain pass (registry-vs-file divergence, silent ?? [] fallback) were adjudicated against the actual source and refuted, so the refactor keeps the contract lock equivalent for the shipped default catalogs.

Reviewed commit: b31f165

@ghost

ghost commented Oct 7, 2026

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The file paths match production registration, and the change preserves the contract-lock checks without introducing a concrete defect.

The scope contract tests now load the project, organization, and account catalogs directly from this repository's configuration files rather than the bootstrap's global registry. Both existing lock assertions remain unchanged, and the catalog provider and lock path are adjusted to match.

Verdict New comments Fixed Still open
✅ Approved 0 0 0
📂 Walkthrough · 1
File Change
tests/unit/General/ScopesTest.php Load repository-local scope catalogs, simplify provider arguments, and share the scopes directory for catalog and lock paths.

Reviewed b31f165 · 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 S · Looks good to merge. Summary

@ChiragAgg5k ChiragAgg5k self-assigned this Oct 7, 2026
@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

Security rules

No new WARNING or ERROR findings from security rules.

32 existing findings tracked in .semgrep/baseline.json
  • php.appwrite.guest-write-without-abuse-limit (17)
  • php.appwrite.permissive-write-permission (8)
  • php.appwrite.secret-compare-timing (5)
  • php.appwrite.weak-secret-env-default (2)

Posted by Checks / Rules. Re-runs update this comment in place. Rule details and baseline: .semgrep/README.md.

@github-actions

github-actions Bot commented Oct 7, 2026

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → fix/scopes-test-own-catalog (after).

Metric Before After Change
🚀 Requests/sec 172.46 169.34 ⚪ -1.8%
⏱️ Latency P50 99.57 ms 100.14 ms ⚪ +0.6%
⏱️ Latency P95 236.32 ms 247.67 ms ⚪ +4.8%
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 100.14 247.67 10,545 169.34 +11.35
Account 203.08 410.62 555 9.24 +35.74
TablesDB 96.56 191.77 5,735 93.91 +5.05
Storage 93.11 207.09 2,775 47.25 +8.78
Functions 146.57 297.04 1,480 25.88 +7.73

Top API waits (after)

API request Max wait (ms)
account.name.update 595.76
functions.create 507.75
functions.variables.update 455.79
functions.delete 440.36
tablesdb.rows.create 435.29

@ChiragAgg5k
ChiragAgg5k merged commit 8a47c4b into main Oct 7, 2026
54 checks passed
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