Skip to content

Conversation

ChiragAgg5k
Copy link
Member

@ChiragAgg5k ChiragAgg5k commented Sep 4, 2025

Summary by CodeRabbit

  • New Features

    • Generated TypeScript SDK models (Web and React Native) now use mutable properties (readonly removed).
  • Bug Fixes

    • CLI push: more reliable table column creation with clearer progress and a timeout error if creation stalls.
  • Refactor

    • Standardized MFA capitalization across CLI login and prompts (no behavior change).
  • Chores

    • SDKs are now generated from the Console API specification, aligning endpoints and models with the Console surface.

Copy link

coderabbitai bot commented Sep 4, 2025

Walkthrough

  • example.php: In getSSLPage, platform value changed from 'server' to 'console', switching the Swagger spec URL from swagger2-1.8.x-server.json to swagger2-1.8.x-console.json.
  • templates/cli/lib/commands/generic.js.twig: Renamed MFA-related functions and prompts from Mfa/MfaChallenge to MFA/MFAChallenge and updated login flow calls; accountUpdateMFAChallenge now receives an added sdk: client parameter.
  • templates/cli/lib/commands/push.js.twig: Added createColumns(columns, table) which creates non-child columns, polls for attribute creation with timeout handling, and replaced createAttributes call with createColumns in pushTable.
  • templates/cli/lib/questions.js.twig: Renamed accountListMfaFactors → accountListMFAFactors and questionsMfaChallenge → questionsMFAChallenge; updated exports and usages.
  • templates/react-native/src/models.ts.twig and templates/web/src/models.ts.twig: Removed generation of the TypeScript readonly modifier for model properties so properties are emitted without readonly.

Possibly related PRs

Suggested reviewers

  • ItzNotABug
  • abnegate

📜 Recent review details

Configuration used: CodeRabbit UI

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 011e633 and 83e077d.

📒 Files selected for processing (1)
  • templates/cli/lib/commands/push.js.twig (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • templates/cli/lib/commands/push.js.twig
⏰ 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). (2)
  • GitHub Check: build (8.3, AppleSwift56)
  • GitHub Check: build (8.3, Android5Java17)
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-push-attributes

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 or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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.

Copy link

@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

🧹 Nitpick comments (5)
example.php (1)

42-42: Parameterize the spec platform via environment variable
Avoid hardcoding 'console'; use an env var with a fallback to preserve the current behavior. Verified that the default console spec URL returns HTTP 200.

-    $platform = 'console';
+    $platform = getenv('APPWRITE_SPEC_PLATFORM') ?: 'console';
templates/cli/lib/commands/push.js.twig (1)

921-939: Await only created columns and report accurate count.

Currently, you await all non-child table.columns and always log columns.length, which may include child columns or columns not created in this batch. Awaiting just the created subset and logging its count makes the step faster and the message accurate.

Apply:

 const createColumns = async (columns, table) => {
-    for (let column of columns) {
+    for (let column of columns) {
         if (column.side !== 'child') {
             await createAttribute(table['databaseId'], table['$id'], column);
         }
     }
 
-    const result = await awaitPools.expectAttributes(
-        table['databaseId'],
-        table['$id'],
-        table.columns.filter(column => column.side !== 'child').map(column => column.key)
-    );
+    const keysToAwait = columns
+        .filter(column => column.side !== 'child')
+        .map(column => column.key);
+
+    const result = await awaitPools.expectAttributes(
+        table['databaseId'],
+        table['$id'],
+        keysToAwait
+    );
 
     if (!result) {
         throw new Error(`Column creation timed out.`);
     }
 
-    success(`Created ${columns.length} columns`);
+    success(`Created ${keysToAwait.length} columns`);
 }
templates/cli/lib/commands/generic.js.twig (3)

75-80: Validate MFA factor before creating a challenge.

Guard against unsupported factors to fail fast with a clear error.

             const { factor } = mfa ? { factor: mfa } : await inquirer.prompt(questionsListFactors);

+            const allowedFactors = ['totp', 'email', 'phone', 'recoveryCode'];
+            if (!allowedFactors.includes(factor)) {
+                throw new Error(`Unsupported MFA factor: ${factor}`);
+            }
+
             const challenge = await accountCreateMFAChallenge({
                 factor,
                 parseOutput: false,
                 sdk: client
             });

83-89: Harden error handling for invalid/expired MFA codes.

Wrap the update call to translate common OTP errors into a clearer message while preserving unexpected errors.

-            await accountUpdateMFAChallenge({
-                challengeId: challenge.$id,
-                otp,
-                parseOutput: false,
-                sdk: client
-            });
+            try {
+                await accountUpdateMFAChallenge({
+                    challengeId: challenge.$id,
+                    otp,
+                    parseOutput: false,
+                    sdk: client
+                });
+            } catch (e) {
+                // Adjust conditions to your SDK's error codes if different
+                if (e?.response === 'user_mfa_challenge_invalid' || e?.response === 'user_mfa_code_invalid') {
+                    throw new Error('Invalid or expired MFA code. Please try again.');
+                }
+                throw e;
+            }

97-99: Fix self-hosted hint condition (uses endpoint arg instead of effective endpoint).

Using the raw endpoint arg can show the hint even when the default endpoint is in use (e.g., when endpoint is undefined). Base the check on configEndpoint.

-            if (endpoint !== DEFAULT_ENDPOINT && error.response === 'user_invalid_credentials') {
-                log('Use the --endpoint option for self-hosted instances')
-            }
+            if (configEndpoint === DEFAULT_ENDPOINT && error.response === 'user_invalid_credentials') {
+                hint('If you are using a self-hosted instance, pass --endpoint <url> to target your self-hosted Appwrite.')
+            }
📜 Review details

Configuration used: CodeRabbit UI

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 9b6ef37 and 011e633.

📒 Files selected for processing (6)
  • example.php (1 hunks)
  • templates/cli/lib/commands/generic.js.twig (2 hunks)
  • templates/cli/lib/commands/push.js.twig (2 hunks)
  • templates/cli/lib/questions.js.twig (4 hunks)
  • templates/react-native/src/models.ts.twig (1 hunks)
  • templates/web/src/models.ts.twig (1 hunks)
⏰ 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). (17)
  • GitHub Check: build (8.3, Python39)
  • GitHub Check: build (8.3, WebChromium)
  • GitHub Check: build (8.3, PHP83)
  • GitHub Check: build (8.3, AppleSwift56)
  • GitHub Check: build (8.3, Ruby31)
  • GitHub Check: build (8.3, Python312)
  • GitHub Check: build (8.3, Python311)
  • GitHub Check: build (8.3, Swift56)
  • GitHub Check: build (8.3, KotlinJava17)
  • GitHub Check: build (8.3, DotNet60)
  • GitHub Check: build (8.3, Deno1193)
  • GitHub Check: build (8.3, DartBeta)
  • GitHub Check: build (8.3, KotlinJava8)
  • GitHub Check: build (8.3, FlutterStable)
  • GitHub Check: build (8.3, FlutterBeta)
  • GitHub Check: build (8.3, Android5Java17)
  • GitHub Check: build (8.3, Android14Java17)
🔇 Additional comments (7)
templates/react-native/src/models.ts.twig (1)

14-14: Revert confirmed—no lingering readonly references in RN templates.

  • Ensure release notes mention the mutability change.
  • Update any docs/examples still referencing readonly properties.
templates/web/src/models.ts.twig (1)

17-17: No stale readonly in web models
Search in templates/web for readonly properties returned no matches; types are now mutable as intended.

templates/cli/lib/commands/push.js.twig (1)

1825-1825: Correct callsite update.

Switching from createAttributes to createColumns for TablesDB is the right mapping.

templates/cli/lib/questions.js.twig (2)

8-8: MFA identifier normalization verified
Ran the provided rg search and found no occurrences of accountListMfaFactors or questionsMfaChallenge.


909-922: questionsMFAChallenge rename verified No remaining references to questionsMfaChallenge found across the codebase.

templates/cli/lib/commands/generic.js.twig (2)

81-81: Ensure OTP input is masked in the prompt.

Confirm questionsMFAChallenge defines the OTP question with a password/masked input to avoid echoing secrets on screen.


9-10: Renamed imports verified: no remaining references to old symbols.

Confirmed there are no occurrences of questionsMfaChallenge, accountCreateMfaChallenge, accountUpdateMfaChallenge, or accountListMfaFactors in the codebase; ../questions and ./account export the updated identifiers.

@ChiragAgg5k ChiragAgg5k changed the title Revert "feat: use readonly keyword in document and row model params" fix push columns in tablesdb cli Sep 4, 2025
@loks0n loks0n merged commit 8f410f7 into master Sep 4, 2025
39 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.

2 participants