Skip to content

feat: SDK update for version 20.1.0#306

Merged
ChiragAgg5k merged 1 commit into
masterfrom
dev
May 5, 2026
Merged

feat: SDK update for version 20.1.0#306
ChiragAgg5k merged 1 commit into
masterfrom
dev

Conversation

@ChiragAgg5k
Copy link
Copy Markdown
Member

@ChiragAgg5k ChiragAgg5k commented May 5, 2026

This PR contains updates to the SDK for version 20.1.0.

What's Changed

  • Added --switch and --new flags on appwrite login to explicitly manage multiple saved accounts
  • Fixed appwrite login to verify the current session via the API and clean up stale guest/unauthorized sessions instead of trusting local metadata
  • Updated Cloud account login to normalize endpoints to https://cloud.appwrite.io/v1 and reject regional Cloud endpoints

@ChiragAgg5k ChiragAgg5k changed the title feat: Command Line SDK update for version 20.1.0 feat: SDK update for version 20.1.0 May 5, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 5, 2026

Greptile Summary

This PR bumps the CLI to version 20.1.0 and refactors the login command: it adds --switch and --new flags for explicit multi-account management, replaces local-metadata trust with a live API session check, and normalizes regional Cloud endpoints to https://cloud.appwrite.io/v1. All version strings, install scripts, and the scoop manifest are updated consistently.

Confidence Score: 4/5

Safe to merge; only P2 findings — no data loss or auth regressions identified.

All findings are P2: a duplicated constant that could drift, a helper function with undocumented side effects, and a subtle ordering change in session deduplication. None affect correctness in the normal login/switch flow.

lib/commands/generic.ts (duplicate DEFAULT_ENDPOINT, getCurrentAccount side effects) and lib/config.ts (getSessions deduplication ordering)

Important Files Changed

Filename Overview
lib/commands/generic.ts Core login logic refactored to add --switch/--new flags, API-verified session checks, and regional endpoint rejection; duplicates DEFAULT_ENDPOINT instead of importing from constants.ts
lib/config.ts Added normalizeCloudConsoleEndpoint(); getSessions() deduplication logic updated to prefer current session when merging duplicate cloud endpoints
lib/questions.ts questionsLogin simplified to email/password only; new questionsSwitchAccount list added with endpoint label omitted for cloud default
lib/utils.ts isCloudHostname exported so generic.ts can import and use it in isRegionalCloudEndpoint
lib/constants.ts SDK_VERSION bumped to 20.1.0; DEFAULT_ENDPOINT already exported here but not imported in generic.ts
CHANGELOG.md 20.1.0 release notes added correctly
install.sh Version bumped to 20.1.0
install.ps1 Version bumped to 20.1.0
scoop/appwrite.config.json Version and download URLs bumped to 20.1.0
package.json Version bumped to 20.1.0

Comments Outside Diff (1)

  1. lib/config.ts, line 1226-1236 (link)

    P2 getSessions() deduplication: last non-current session wins

    The new condition existingSession.id !== current is true for any existing entry that is not the current session, so a later non-current duplicate always replaces an earlier non-current one. The previous logic kept the first non-current entry. While the current session is still correctly preferred, the arbitrary ordering for non-current duplicates could surface a session ID that no longer has a valid cookie, hiding the one that does. Consider only replacing if sessionId === current, which is the intent expressed by the old logic.

Reviews (1): Last reviewed commit: "chore: update Command Line SDK to 20.1.0" | Re-trigger Greptile

Comment thread lib/commands/generic.ts
localConfig,
normalizeCloudConsoleEndpoint,
} from "../config.js";
import { EXECUTABLE_NAME } from "../constants.js";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 DEFAULT_ENDPOINT is already exported from lib/constants.ts (which questions.ts and other modules already import). Defining a private duplicate here creates a maintenance risk — if the canonical value ever changes, this copy would silently diverge.

Suggested change
import { EXECUTABLE_NAME } from "../constants.js";
import { EXECUTABLE_NAME, DEFAULT_ENDPOINT } from "../constants.js";

Comment thread lib/commands/generic.ts
} from "@appwrite.io/console";
import ClientLegacy from "../client.js";

const DEFAULT_ENDPOINT = "https://cloud.appwrite.io/v1";
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Duplicate DEFAULT_ENDPOINT constant

This local constant duplicates the exported DEFAULT_ENDPOINT from lib/constants.ts. Remove this line once the import above is updated to include DEFAULT_ENDPOINT.

Comment thread lib/commands/generic.ts
Comment on lines +75 to +98
const getCurrentAccount = async (): Promise<Models.User | null> => {
if (globalConfig.getEndpoint() === "" || globalConfig.getCookie() === "") {
return null;
}

const endpoint = normalizeCloudConsoleEndpoint(globalConfig.getEndpoint());
if (endpoint !== globalConfig.getEndpoint()) {
globalConfig.setEndpoint(endpoint);
}

const client = await sdkForConsole(false);
const accountClient = new Account(client);

try {
const account = await accountClient.get();
globalConfig.setEmail(account.email);
return account;
} catch (err) {
if (isGuestUnauthorizedError(err)) {
removeCurrentSession();
}
return null;
}
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 getCurrentAccount carries silent, destructive side effects

Beyond returning the current user, this function: (1) mutates globalConfig by normalizing and persisting the endpoint on every call, and (2) permanently removes the current session from local config when general_unauthorized_scope is returned. A transient network error (connection refused, timeout) causes the catch block to skip removal and return null, which causes loginCommand to bypass the "already logged in" early-return and re-prompt the user — potentially creating a duplicate session for the same account. At minimum, network errors should be distinguished from authorization errors so callers can decide how to handle each case.

@ChiragAgg5k ChiragAgg5k merged commit 6272056 into master May 5, 2026
2 checks passed
@ChiragAgg5k ChiragAgg5k deleted the dev branch May 5, 2026 12:37
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