8000 chore: add replacewith and deprecated since to account methods by ChiragAgg5k · Pull Request #10377 · appwrite/appwrite · GitHub
[go: up one dir, main page]

Skip to content

Conversation

@ChiragAgg5k
Copy link
Member

… updateMagicURLSession

What does this PR do?

(Provide a description of what this PR does and why it's needed.)

Test Plan

(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)

Related PRs and Issues

  • (Related PR or issue)

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?

@coderabbitai
Copy link
Contributor
coderabbitai bot commented Aug 26, 2025

Warning

Rate limit exceeded

@ChiragAgg5k has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 7 minutes and 29 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6acde0b and 53f778d.

📒 Files selected for processing (1)
  • src/Appwrite/SDK/Specification/Format/OpenAPI3.php (2 hunks)
📝 Walkthrough

Walkthrough

Replaced boolean deprecation markers with nullable Deprecated objects and updated related checks. In app/controllers/api/account.php the sendSessionAlert Method declarations now use new Deprecated(since: '1.6.0', replaceWith: 'account.createSession') instead of deprecated: true. In src/Appwrite/SDK/Method.php the promoted deprecated property and constructor default changed from bool|Deprecated $deprecated = false to ?Deprecated $deprecated = null; isDeprecated() now checks for null and getDeprecated() returns ?Deprecated. OpenAPI3 and Swagger2 formatters now test getDeprecated() for truthiness instead of instanceof Deprecated.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Fix casing #10346 — Related change replacing boolean deprecation flags with Deprecated objects and updating Method/deprecation handling.
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-deprecated-versions-account

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary t 8000 o generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
github-actions bot commented Aug 26, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@pkg-pr-new
Copy link
pkg-pr-new bot commented Aug 26, 2025

Open in StackBlitz

npm i https://pkg.pr.new/appwrite/appwrite/@appwrite.io/console@10377

commit: 53f778d

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
app/controllers/api/account.php (1)

147-152: Nit: PHP date format 'YYYY' is incorrect; should be 'Y'

This is unrelated to the PR scope, but it’s a real user-facing issue: DateTime::format('YYYY') outputs the literal string “YYYY”. Use 'Y' for 4‑digit year.

Apply:

   $emailVariables = [
     'direction' => $locale->getText('settings.direction'),
     'date' => (new \DateTime())->format('F j'),
-    'year' => (new \DateTime())->format('YYYY'),
+    'year' => (new \DateTime())->format('Y'),
     'time' => (new \DateTime())->format('H:i:s'),
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ba401ea and 26228e9.

⛔ Files ignored due to path filters (12)
  • app/config/specs/open-api3-1.8.x-client.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-1.8.x-console.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-1.8.x-server.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-latest-client.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-latest-console.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-latest-server.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-1.8.x-client.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-1.8.x-console.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-1.8.x-server.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-latest-client.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-latest-console.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-latest-server.json is excluded by !app/config/specs/**
📒 Files selected for processing (1)
  • app/controllers/api/account.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
app/controllers/api/account.php (1)
src/Appwrite/SDK/Deprecated.php (1)
  • Deprecated (5-32)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build SDK
  • GitHub Check: scan
🔇 Additional comments (1)
app/controllers/api/account.php (1)

2422-2425: Deprecation Version Verified

I’ve confirmed that both the updateMagicURLSession (around line 2422) and updatePhoneSession (around line 2463) endpoints in app/controllers/api/account.php carry since: '0.16.0', matching each other and indicating they were deprecated in v0.16.0. The later 1.8.0 deprecations apply only to the MFA-related endpoints, so no version alignment changes are needed here.

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
src/Appwrite/SDK/Specification/Format/Swagger2.php (1)

6-6: Fix linter failure: remove unused import

Pipeline reports PSR-12 no_unused_imports for this file. Deprecated is no longer referenced after switching away from instanceof checks. Remove the unused import to make Pint green.

Apply this diff:

 use Appwrite\SDK\AuthType;
-use Appwrite\SDK\Deprecated;
 use Appwrite\SDK\Method;
src/Appwrite/SDK/Method.php (2)

280-284: Bug: setDeprecated accepts bool but assigns into ?Deprecated-typed property

The setter still accepts bool|Deprecated and directly assigns to a property typed ?Deprecated. Passing a boolean will trigger a TypeError at runtime. This is a regression introduced by the new property type and is likely to bite existing call sites.

Apply this diff to make the API coherent with the new contract:

-    public function setDeprecated(bool|Deprecated $deprecated): self
+    public function setDeprecated(?Deprecated $deprecated): self
     {
         $this->deprecated = $deprecated;
         return $this;
     }

If backward compatibility with boolean callers is required, add a temporary shim that rejects booleans explicitly and guides callers to construct Deprecated, e.g.:

public function setDeprecated(?Deprecated $deprecated): self
{
    $this->deprecated = $deprecated;
    return $this;
}

/** @deprecated Pass Deprecated|null instead */
public function setDeprecatedFlag(bool $flag): self
{
    if ($flag) {
        throw new \LogicException('Boolean deprecation flags are no longer supported. Pass an instance of Deprecated with since/replaceWith.');
    }
    $this->deprecated = null;
    return $this;
}

35-60: Remaining Boolean “deprecated” Flags Found – Action Required

The grep run identifies legacy boolean flags still in use within src/Appwrite/Platform/Modules/Functions/Http/Functions/Create.php (lines 101–104):

  • Four calls to ->param(…, true, deprecated: true)

These must be replaced with proper Deprecated instances (e.g. new Deprecated('sinceVersion', 'replacementMethod')) to align with the updated setter and constructor.

• Update these four ->param(…) invocations to pass a Deprecated object instead of deprecated: true.
• Verify any other service or route metadata for similar boolean deprecation flags and refactor accordingly.

🧹 Nitpick comments (2)
src/Appwrite/SDK/Specification/Format/OpenAPI3.php (1)

170-175: Unify deprecation checks (truthy vs instanceof) for consistency

Top-level still uses instanceof Deprecated while additional methods use a truthy check. Both are correct given getDeprecated(): ?Deprecated, but using the same style improves readability and avoids an unnecessary import.

Apply this diff to align with the rest of the code:

-            if ($sdk->getDeprecated() instanceof Deprecated) {
+            if ($sdk->getDeprecated()) {
                 $temp['x-appwrite']['deprecated'] = [
                     'since' => $sdk->getDeprecated()->getSince(),
                     'replaceWith' => $sdk->getDeprecated()->getReplaceWith(),
                 ];
             }

Optionally remove the now-unused import:

 use Appwrite\SDK\AuthType;
-use Appwrite\SDK\Deprecated;
 use Appwrite\SDK\Method;
src/Appwrite/SDK/Method.php (1)

286-291: Typo in setHide signature: should be bool|array, not bool|Deprecated

setHide’s parameter type doesn’t match the property (array|bool) and return type doc (bool|array). This predates the PR but becomes more confusing next to the deprecation changes.

Apply this diff:

-    public function setHide(bool|Deprecated $hide): self
+    public function setHide(bool|array $hide): self
     {
         $this->hide = $hide;
         return $this;
     }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 26228e9 and 5a35f13.

⛔ Files ignored due to path filters (12)
  • app/config/specs/open-api3-1.8.x-client.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-1.8.x-console.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-1.8.x-server.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-latest-client.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-latest-console.json is excluded by !app/config/specs/**
  • app/config/specs/open-api3-latest-server.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-1.8.x-client.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-1.8.x-console.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-1.8.x-server.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-latest-client.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-latest-console.json is excluded by !app/config/specs/**
  • app/config/specs/swagger2-latest-server.json is excluded by !app/config/specs/**
📒 Files selected for processing (4)
  • app/controllers/api/account.php (2 hunks)
  • src/Appwrite/SDK/Method.php (3 hunks)
  • src/Appwrite/SDK/Specification/Format/OpenAPI3.php (1 hunks)
  • src/Appwrite/SDK/Specification/Format/Swagger2.php (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/controllers/api/account.php
🧰 Additional context used
🧬 Code graph analysis (3)
src/Appwrite/SDK/Specification/Format/OpenAPI3.php (1)
src/Appwrite/SDK/Method.php (1)
  • getDeprecated (191-194)
src/Appwrite/SDK/Specification/Format/Swagger2.php (1)
src/Appwrite/SDK/Method.php (1)
  • getDeprecated (191-194)
src/Appwrite/SDK/Method.php (1)
src/Appwrite/SDK/Deprecated.php (1)
  • Deprecated (5-32)
🪛 GitHub Actions: Linter
src/Appwrite/SDK/Specification/Format/Swagger2.php

[error] 1-1: Pint lint failed: PSR-12 no_unused_imports. Unused import detected in Swagger2.php. Reproduce with 'vendor/bin/pint --test --config pint.json'.

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (18)
  • GitHub Check: E2E Service Test (Webhooks)
  • GitHub Check: E2E Service Test (Console)
  • GitHub Check: E2E Service Test (Storage)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Teams)
  • GitHub Check: E2E Service Test (Databases/TablesDB)
  • GitHub Check: E2E Service Test (Databases/Legacy)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Service Test (Tokens)
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (Health)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (Site Screenshots)
  • GitHub Check: E2E General Test
  • GitHub Check: Setup & Build Appwrite Image
  • GitHub Check: Setup & Build SDK
  • GitHub Check: scan
🔇 Additional comments (5)
src/Appwrite/SDK/Specification/Format/Swagger2.php (2)

174-179: Good switch to nullable Deprecated check

Using a truthy check against getDeprecated() aligns with Method::getDeprecated(): ?Deprecated and keeps the code concise. The subsequent dereference is safe when the condition passes.


238-243: Consistent handling for additional methods

Same rationale here—truthy check is correct and consistent with the new nullable Deprecated type.

src/Appwrite/SDK/Specification/Format/OpenAPI3.php (1)

229-234: Truthy deprecation check for additional methods looks good

Matches the new Method::getDeprecated(): ?Deprecated contract.

src/Appwrite/SDK/Method.php (2)

27-28: Migration to nullable Deprecated on ctor/property is correct

Switching to Deprecated|null on the constructor doc and the promoted property is aligned with the new semantics and with getDeprecated(): ?Deprecated.

Also applies to: 44-45


188-189: isDeprecated()/getDeprecated() updates are sound

isDeprecated now checks against null, and getDeprecated returns ?Deprecated—both consistent with the property type.

Also applies to: 191-194

Copy link
Contributor
@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/Appwrite/SDK/Specification/Format/Swagger2.php (1)

163-163: Fix null-coalescing precedence bug in the “edit” URL

Without parentheses, the ?? '' applies to the concatenation result, not to $sdk->getDescription(). This yields a dangling base URL when description is null.

Apply this diff:

-                    'edit' => 'https://github.com/appwrite/appwrite/edit/master' .  $sdk->getDescription() ?? '',
+                    'edit' => 'https://github.com/appwrite/appwrite/edit/master' . ($sdk->getDescription() ?? ''),
🧹 Nitpick comments (2)
src/Appwrite/SDK/Specification/Format/Swagger2.php (2)

173-178: Prefer explicit null-check and cache Deprecated to avoid repeated calls

Given Method::getDeprecated(): ?Deprecated, an explicit null check improves readability and avoids three identical calls in this block.

Apply this diff:

-            if ($sdk->getDeprecated()) {
-                $temp['x-appwrite']['deprecated'] = [
-                    'since' => $sdk->getDeprecated()->getSince(),
-                    'replaceWith' => $sdk->getDeprecated()->getReplaceWith(),
-                ];
-            }
+            $deprecated = $sdk->getDeprecated();
+            if (null !== $deprecated) {
+                $temp['x-appwrite']['deprecated'] = [
+                    'since' => $deprecated->getSince(),
+                    'replaceWith' => $deprecated->getReplaceWith(),
+                ];
+            }

237-242: Mirror the same explicit null-check/caching for additional methods

Minor consistency/readability improvement; also avoids repeated calls in this loop.

Apply this diff:

-                    if ($methodObj->getDeprecated()) {
-                        $additionalMethod['deprecated'] = [
-                            'since' => $methodObj->getDeprecated()->getSince(),
-                            'replaceWith' => $methodObj->getDeprecated()->getReplaceWith(),
-                        ];
-                    }
+                    $deprecated = $methodObj->getDeprecated();
+                    if (null !== $deprecated) {
+                        $additionalMethod['deprecated'] = [
+                            'since' => $deprecated->getSince(),
+                            'replaceWith' => $deprecated->getReplaceWith(),
+                        ];
+                    }
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5a35f13 and 6acde0b.

📒 Files selected for processing (1)
  • src/Appwrite/SDK/Specification/Format/Swagger2.php (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/Appwrite/SDK/Specification/Format/Swagger2.php (1)
src/Appwrite/SDK/Method.php (1)
  • getDeprecated (191-194)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (16)
  • GitHub Check: Benchmark
  • GitHub Check: E2E Service Test (Proxy)
  • GitHub Check: E2E Service Test (VCS)
  • GitHub Check: E2E Service Test (Sites)
  • GitHub Check: E2E Service Test (Tokens)
  • GitHub Check: E2E Service Test (Webhooks)
  • GitHub Check: E2E Service Test (Messaging)
  • GitHub Check: E2E Service Test (Functions)
  • GitHub Check: E2E Service Test (Realtime)
  • GitHub Check: E2E Service Test (Databases/Legacy)
  • GitHub Check: E2E Service Test (Account)
  • GitHub Check: E2E Service Test (Databases/TablesDB)
  • GitHub Check: E2E Service Test (GraphQL)
  • GitHub Check: E2E Service Test (FunctionsSchedule)
  • GitHub Check: E2E Service Test (Avatars)
  • GitHub Check: E2E Service Test (Site Screenshots)

@github-actions
Copy link

✨ Benchmark results

  • Requests per second: 1,266
  • Requests with 200 status code: 227,928
  • P99 latency: 0.152326899

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,266 970
200 227,928 174,670
P99 0.152326899 0.199487088

@loks0n loks0n merged commit 9fc39dd into 1.8.x Aug 26, 2025
42 of 43 checks passed
@ChiragAgg5k ChiragAgg5k deleted the add-deprecated-versions-account branch September 15, 2025 04:59
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.

4 participants

0