[PR #799] [MERGED] fix: ensure emailForwardingList is always initialized #771

Closed
opened 2026-02-26 21:32:53 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/dreamhunter2333/cloudflare_temp_email/pull/799
Author: @dreamhunter2333
Created: 12/30/2025
Status: Merged
Merged: 12/30/2025
Merged by: @dreamhunter2333

Base: mainHead: feature/email


📝 Commits (1)

  • 1741dff fix: ensure emailForwardingList is always initialized

📊 Changes

1 file changed (+3 additions, -3 deletions)

View changed files

📝 frontend/src/views/admin/AccountSettings.vue (+3 -3)

📄 Description

User description

Summary

  • Fix frontend emailRuleSettings initialization to prevent SyntaxError when adding email forwarding rules
  • Ensure emailForwardingList is always an array instead of undefined

Problem

When backend returns emailRuleSettings without emailForwardingList field, the frontend would get undefined instead of an empty array, causing a SyntaxError when clicking the "Add" button in email forwarding configuration.

Solution

Use optional chaining to safely access and initialize both fields of emailRuleSettings:

emailRuleSettings.value = {
    blockReceiveUnknowAddressEmail: res.emailRuleSettings?.blockReceiveUnknowAddressEmail || false,
    emailForwardingList: res.emailRuleSettings?.emailForwardingList || []
}

Test Plan

  • Build frontend successfully
  • Open account settings page without errors
  • Click "Add" button in email forwarding config without SyntaxError
  • Verify forwarding rules can be added and saved

🤖 Generated with Claude Code


PR Type

Bug fix


Description

  • Fix initialization of emailRuleSettings to prevent errors.

  • Ensure emailForwardingList is always an array.

  • Use optional chaining for safer field access.

  • Prevent SyntaxError when adding email forwarding rules.


Changes walkthrough 📝

Relevant files
Bug fix
AccountSettings.vue
Fix and enhance emailRuleSettings initialization logic     

frontend/src/views/admin/AccountSettings.vue

  • Updated emailRuleSettings initialization logic.
  • Used optional chaining for safer field access.
  • Ensured emailForwardingList defaults to an empty array.
  • +3/-3     

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.

  • 🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

    ## 📋 Pull Request Information **Original PR:** https://github.com/dreamhunter2333/cloudflare_temp_email/pull/799 **Author:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Created:** 12/30/2025 **Status:** ✅ Merged **Merged:** 12/30/2025 **Merged by:** [@dreamhunter2333](https://github.com/dreamhunter2333) **Base:** `main` ← **Head:** `feature/email` --- ### 📝 Commits (1) - [`1741dff`](https://github.com/dreamhunter2333/cloudflare_temp_email/commit/1741dff2d344ae3cab5eaec20c599d397adf5bde) fix: ensure emailForwardingList is always initialized ### 📊 Changes **1 file changed** (+3 additions, -3 deletions) <details> <summary>View changed files</summary> 📝 `frontend/src/views/admin/AccountSettings.vue` (+3 -3) </details> ### 📄 Description ### **User description** ## Summary - Fix frontend emailRuleSettings initialization to prevent SyntaxError when adding email forwarding rules - Ensure emailForwardingList is always an array instead of undefined ## Problem When backend returns `emailRuleSettings` without `emailForwardingList` field, the frontend would get `undefined` instead of an empty array, causing a SyntaxError when clicking the "Add" button in email forwarding configuration. ## Solution Use optional chaining to safely access and initialize both fields of emailRuleSettings: ```typescript emailRuleSettings.value = { blockReceiveUnknowAddressEmail: res.emailRuleSettings?.blockReceiveUnknowAddressEmail || false, emailForwardingList: res.emailRuleSettings?.emailForwardingList || [] } ``` ## Test Plan - [x] Build frontend successfully - [x] Open account settings page without errors - [x] Click "Add" button in email forwarding config without SyntaxError - [x] Verify forwarding rules can be added and saved 🤖 Generated with [Claude Code](https://claude.ai/code) ___ ### **PR Type** Bug fix ___ ### **Description** - Fix initialization of `emailRuleSettings` to prevent errors. - Ensure `emailForwardingList` is always an array. - Use optional chaining for safer field access. - Prevent SyntaxError when adding email forwarding rules. ___ ### **Changes walkthrough** 📝 <table><thead><tr><th></th><th align="left">Relevant files</th></tr></thead><tbody><tr><td><strong>Bug fix</strong></td><td><table> <tr> <td> <details> <summary><strong>AccountSettings.vue</strong><dd><code>Fix and enhance emailRuleSettings initialization logic</code>&nbsp; &nbsp; &nbsp; </dd></summary> <hr> frontend/src/views/admin/AccountSettings.vue <li>Updated <code>emailRuleSettings</code> initialization logic.<br> <li> Used optional chaining for safer field access.<br> <li> Ensured <code>emailForwardingList</code> defaults to an empty array. </details> </td> <td><a href="https://github.com/dreamhunter2333/cloudflare_temp_email/pull/799/files#diff-d5db89bc5b7ac5d009a78d299aa22f0f0414bbbb5006e88b30f35af8510b6b33">+3/-3</a>&nbsp; &nbsp; &nbsp; </td> </tr> </table></td></tr></tr></tbody></table> ___ > <details> <summary> Need help?</summary><li>Type <code>/help how to ...</code> in the comments thread for any questions about PR-Agent usage.</li><li>Check out the <a href="https://qodo-merge-docs.qodo.ai/usage-guide/">documentation</a> for more information.</li></details> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
    kerem 2026-02-26 21:32:53 +03:00
    Sign in to join this conversation.
    No milestone
    No project
    No assignees
    1 participant
    Notifications
    Due date
    The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

    No due date set.

    Dependencies

    No dependencies set.

    Reference
    starred/cloudflare_temp_email#771
    No description provided.