Skip to content

fix: templates not being used for custom smtp#2865

Open
HarshMN2345 wants to merge 1 commit intomainfrom
fix-templates
Open

fix: templates not being used for custom smtp#2865
HarshMN2345 wants to merge 1 commit intomainfrom
fix-templates

Conversation

@HarshMN2345
Copy link
Member

@HarshMN2345 HarshMN2345 commented Feb 17, 2026

What does this PR do?

(Provide a description of what this PR does.)

Test Plan

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • Refactor
    • Updated internal email template key definitions for improved code consistency.

@appwrite
Copy link

appwrite bot commented Feb 17, 2026

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

Tip

HTTPS and SSL certificates are handled automatically for all your Sites

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 17, 2026

Walkthrough

This pull request updates four email template key declarations in a single file by replacing enum member references with string literals cast as the same type. Specifically, four entries in the templates array have their key properties modified from EmailTemplateType.Magicsession, EmailTemplateType.Otpsession, EmailTemplateType.Mfachallenge, and EmailTemplateType.Sessionalert to their respective string literal equivalents ('magicSession', 'otpSession', 'mfaChallenge', 'sessionAlert'), each cast as EmailTemplateType. No functional logic, control flow, or error handling changes are present.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~5 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title references fixing templates for custom SMTP, which aligns with the actual code changes that convert enum members to string literals for template keys.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-templates

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

Comment @coderabbitai help to get the list of available commands and usage tips.

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

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/routes/`(console)/project-[region]-[project]/auth/templates/store.ts:
- Line 54: Add a brief TODO comment on each of the four lines that use string
assertions for EmailTemplateType—specifically the keys "'magicSession' as
EmailTemplateType", "'otpSession' as EmailTemplateType", "'mfaChallenge' as
EmailTemplateType", and "'sessionAlert' as EmailTemplateType"—explaining this is
a temporary workaround because the `@appwrite.io/console` SDK enum members (e.g.,
Magicsession, Otpsession, Mfachallenge, Sessionalert) use all-lowercase values
that don't match the API's camelCase template names, that the type assertion
bypasses type safety, and that the TODO should be removed once the SDK enum is
corrected.

},
{
key: EmailTemplateType.Magicsession,
key: 'magicSession' as EmailTemplateType,
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Find the EmailTemplateType enum definition in the installed package
find node_modules -name "*.d.ts" -o -name "*.ts" 2>/dev/null | head -20

Repository: appwrite/console

Length of output: 3816


🏁 Script executed:

# Search for EmailTemplateType enum definition
rg "enum EmailTemplateType|export.*EmailTemplateType" --type ts --type js -A 15

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

# Look at the file context to understand the usage
head -100 src/routes/\(console\)/project-\[region\]-\[project\]/auth/templates/store.ts | tail -60

Repository: appwrite/console

Length of output: 1872


🏁 Script executed:

# Check if the file imports EmailTemplateType and how it's used
grep -n "EmailTemplateType\|import.*Email" "src/routes/(console)/project-[region]-[project]/auth/templates/store.ts"

Repository: appwrite/console

Length of output: 978


🏁 Script executed:

find node_modules -path "*@appwrite.io/console*" -name "*.d.ts" -o -path "*@appwrite.io/console*" -name "*.ts" 2>/dev/null | grep -v ".test\|.spec" | head -20

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

find node_modules -path "*@appwrite.io/console*" -type f \( -name "*.d.ts" -o -name "*.js" \) 2>/dev/null | head -30

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

rg "enum EmailTemplateType|export.*EmailTemplateType" node_modules/@appwrite.io/console -A 20 2>/dev/null

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

rg "EmailTemplateType" node_modules 2>/dev/null | head -20

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

find node_modules -type f -name "*.d.ts" | xargs grep -l "EmailTemplateType" 2>/dev/null | head -10

Repository: appwrite/console

Length of output: 42


🏁 Script executed:

ls -la node_modules/@appwrite.io/ 2>/dev/null || ls -la node_modules/ | grep appwrite

Repository: appwrite/console

Length of output: 614


🏁 Script executed:

rg "EmailTemplateType" --type ts --type js -B 2 -A 10 | head -100

Repository: appwrite/console

Length of output: 6429


🏁 Script executed:

find src -type f \( -name "*.ts" -o -name "*.d.ts" \) | xargs grep -l "enum EmailTemplateType\|export.*EmailTemplateType" 2>/dev/null

Repository: appwrite/console

Length of output: 44


🏁 Script executed:

cat package.json | grep -A 5 -B 5 "@appwrite.io/console"

Repository: appwrite/console

Length of output: 639


🏁 Script executed:

find src -type f \( -name "*.ts" -o -name "*.d.ts" \) | xargs grep -l "enum.*EmailTemplateType\|export.*EmailTemplateType.*=" 2>/dev/null

Repository: appwrite/console

Length of output: 44


🏁 Script executed:

rg "enum EmailTemplateType|EmailTemplateType\s*=" --type ts --type tsx -B 2 -A 15

Repository: appwrite/console

Length of output: 87


🏁 Script executed:

# Check if there's a types or lib folder
find . -maxdepth 3 -type d -name "types" -o -name "lib" -o -name "@appwrite.io" 2>/dev/null | grep -v node_modules

Repository: appwrite/console

Length of output: 69


🏁 Script executed:

# Look at git history to understand what changed
git log --oneline -20 -- "src/routes/(console)/project-[region]-[project]/auth/templates/store.ts" 2>/dev/null

Repository: appwrite/console

Length of output: 115


🏁 Script executed:

git show 1405f4231 -- "src/routes/(console)/project-[region]-[project]/auth/templates/store.ts" 2>/dev/null | head -100

Repository: appwrite/console

Length of output: 3475


🏁 Script executed:

# Look in src/lib for type definitions
find src/lib -type f \( -name "*.ts" -o -name "*.d.ts" \) | head -20

Repository: appwrite/console

Length of output: 782


🌐 Web query:

@appwrite.io/console EmailTemplateType enum members

💡 Result:

In Appwrite, the email template types (exposed as EmailTemplateType in the Console SDK @appwrite.io/console) correspond to these built-in template categories:

  • Account verification
  • Magic URL authentication
  • Password reset
  • User invite (appwrite.io)

Citations:


🌐 Web query:

appwrite console SDK EmailTemplateType magicSession otpSession

💡 Result:

In the Appwrite Console SDK (@appwrite.io/console), the EmailTemplateType enum uses Magicsession and Otpsession (not magicSession / otpSession) and they map to these string values: "magicsession" and "otpsession". [1]

import { EmailTemplateType } from '@appwrite.io/console';

EmailTemplateType.Magicsession; // "magicsession"
EmailTemplateType.Otpsession;   // "otpsession"

These correspond to the email templates used for Magic URL login and Email OTP login flows in Appwrite. [2][3]

Sources
[1] Appwrite Console SDK types: email-template-type.d.ts (jsDelivr)
[2] Appwrite Docs: Email OTP
[3] Appwrite Docs: Message templates / email templates


Add TODO comments documenting the enum value mismatch workaround.

The four changed keys use '...' as EmailTemplateType type assertions because the @appwrite.io/console SDK's enum members (Magicsession, Otpsession, Mfachallenge, Sessionalert) hold all-lowercase string values ("magicsession", "otpsession", etc.), which don't match the camelCase strings the API expects ("magicSession", "otpSession", etc.). Using as EmailTemplateType bypasses type safety—if the SDK is ever updated with correct enum members, this code won't be caught by the type system.

Add // TODO comments to each of the four lines (54, 60, 78, 84) explaining the workaround, following the guideline to comment complex logic. Example:

-        key: 'magicSession' as EmailTemplateType,
+        // TODO: Use EmailTemplateType.MagicSession once SDK enum is corrected
+        key: 'magicSession' as EmailTemplateType,

The inconsistency of mixing three direct enum references (Verification, Recovery, Invitation) with four string literal assertions should be resolved once the SDK is fixed.

Also applies to: 60-60, 78-78, 84-84

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/routes/`(console)/project-[region]-[project]/auth/templates/store.ts at
line 54, Add a brief TODO comment on each of the four lines that use string
assertions for EmailTemplateType—specifically the keys "'magicSession' as
EmailTemplateType", "'otpSession' as EmailTemplateType", "'mfaChallenge' as
EmailTemplateType", and "'sessionAlert' as EmailTemplateType"—explaining this is
a temporary workaround because the `@appwrite.io/console` SDK enum members (e.g.,
Magicsession, Otpsession, Mfachallenge, Sessionalert) use all-lowercase values
that don't match the API's camelCase template names, that the type assertion
bypasses type safety, and that the TODO should be removed once the SDK enum is
corrected.

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