[PR #3689] [MERGED] HBE-343 hotfix: improve smtp email validation and fix enableAndDisableSSO mutation #4491

Closed
opened 2026-03-17 02:01:29 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/hoppscotch/hoppscotch/pull/3689
Author: @mirarifhasan
Created: 12/22/2023
Status: Merged
Merged: 12/22/2023
Merged by: @AndrewBastin

Base: 2023.12.1Head: hotfix/server-config-enabling


📝 Commits (7)

  • 8abae01 fix: added a database call find in infra_config for isServiceConfigured func
  • 9102984 feat: add smtp email validation
  • 8299d4f feat: add validation in adding providers
  • 61a5f60 chore: feedback resolve
  • 920867c chore: move code block to separate function
  • 9e312e0 chore: added link to nodemailer docs
  • c157db0 chore: removed regex's outside validateSMTPEmail function

📊 Changes

5 files changed (+123 additions, -24 deletions)

View changed files

📝 packages/hoppscotch-backend/src/errors.ts (+7 -0)
📝 packages/hoppscotch-backend/src/infra-config/helper.ts (+62 -0)
📝 packages/hoppscotch-backend/src/infra-config/infra-config.service.ts (+30 -23)
📝 packages/hoppscotch-backend/src/main.ts (+2 -1)
📝 packages/hoppscotch-backend/src/utils.ts (+22 -0)

📄 Description

Closes HBE-343

Description

This PR fixed the following issues in hoppscotch-backend package

  1. Improve SMTP email validation by allowing a total of 3 formats that the nodemailer npm package allows. https://nodemailer.com/message/addresses.
    This error encountered when updateInfraConfigs mutation called.

  2. To resolve error on enableAndDisableSSO mutation, introduced Database call findMany() instead of configService.get() to get latest data

Current Problem

  1. Regarding the SMTP email format
    The npm Nodemailer package has 3 acceptable formats where hoppscotch-backend previously accepts only email as MAILER_ADDRESS_FROM.
Backend Server | [Nest] 65  - 12/19/2023, 5:46:40 PM   ERROR [ExceptionsHandler] infra_config/invalid_input 
Backend Server | Error: infra_config/invalid_input 
Backend Server |     at throwErr (/usr/src/app/packages/hoppscotch-backend/dist/utils.js:14:11) 
Backend Server |     at InfraResolver.updateInfraConfigs (/usr/src/app/packages/hoppscotch-backend/dist/admin/infra.resolver.js:121:34)
  1. When enableAndDisableSSO mutation called, is checks isServiceConfigured with old data from configService instead of new data from database.
{ "errors": [ { 
    "message": "infra_config/service_not_configured", 
    "locations": [ { "line": 2, "column": 3 } ], 
    "path": [ "enableAndDisableSSO" ], 
    "extensions": { 
      "code": "INTERNAL_SERVER_ERROR", 
      "stacktrace": [ "Error: infra_config/service_not_configured", 
      "    at throwErr (/usr/src/app/packages/hoppscotch-backend/dist/utils.js:14:11)", 
      "    at InfraConfigService.enableAndDisableSSO (/usr/src/app/packages/hoppscotch-backend/dist/infra-config/infra-config.service.js:167:42)", 
      "    at InfraResolver.enableAndDisableSSO (/usr/src/app/packages/hoppscotch-backend/dist/admin/infra.resolver.js:131:57)", 
      "    at /usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/helpers/external-context-creator.js:67:33", 
      "    at async target (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/helpers/external-context-creator.js:74:28)", 
      "    at async Object.enableAndDisableSSO (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/helpers/external-proxy.js:9:24)" ] } 
   } ], 
  "data": null }

Testing Instruction

  1. Test updateInfraConfigs mutation to update MAILER_ADDRESS_FROM
  2. Test enableAndDisableSSO mutation

Checks

  • My pull request adheres to the code style of this project
  • My code requires changes to the documentation
  • I have updated the documentation as required
  • All the tests have passed

Additional Information

Nil


🔄 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/hoppscotch/hoppscotch/pull/3689 **Author:** [@mirarifhasan](https://github.com/mirarifhasan) **Created:** 12/22/2023 **Status:** ✅ Merged **Merged:** 12/22/2023 **Merged by:** [@AndrewBastin](https://github.com/AndrewBastin) **Base:** `2023.12.1` ← **Head:** `hotfix/server-config-enabling` --- ### 📝 Commits (7) - [`8abae01`](https://github.com/hoppscotch/hoppscotch/commit/8abae01730dbb5bac553817deaebd4250e5c504e) fix: added a database call find in infra_config for isServiceConfigured func - [`9102984`](https://github.com/hoppscotch/hoppscotch/commit/91029847c4190358fdab1b269bd2287703a60b72) feat: add smtp email validation - [`8299d4f`](https://github.com/hoppscotch/hoppscotch/commit/8299d4f1f63249629bdd254670f47dc6ffb457b0) feat: add validation in adding providers - [`61a5f60`](https://github.com/hoppscotch/hoppscotch/commit/61a5f60105889878cf62353a24aa71ce468aec56) chore: feedback resolve - [`920867c`](https://github.com/hoppscotch/hoppscotch/commit/920867c5600dc47855db0f89e247cd4c765bee1e) chore: move code block to separate function - [`9e312e0`](https://github.com/hoppscotch/hoppscotch/commit/9e312e0d260fcfe2a8f4910355577cd739550630) chore: added link to nodemailer docs - [`c157db0`](https://github.com/hoppscotch/hoppscotch/commit/c157db00b76c037210064057f2d3e8903087974e) chore: removed regex's outside validateSMTPEmail function ### 📊 Changes **5 files changed** (+123 additions, -24 deletions) <details> <summary>View changed files</summary> 📝 `packages/hoppscotch-backend/src/errors.ts` (+7 -0) 📝 `packages/hoppscotch-backend/src/infra-config/helper.ts` (+62 -0) 📝 `packages/hoppscotch-backend/src/infra-config/infra-config.service.ts` (+30 -23) 📝 `packages/hoppscotch-backend/src/main.ts` (+2 -1) 📝 `packages/hoppscotch-backend/src/utils.ts` (+22 -0) </details> ### 📄 Description <!-- Thanks for creating this pull request 🤗 Please make sure that the pull request is limited to one type (docs, feature, etc.) and keep it as small as possible. You can open multiple prs instead of opening a huge one. --> <!-- If this pull request closes an issue, please mention the issue number below --> <!-- Issue # here --> Closes HBE-343 ### Description <!-- Add a brief description of the pull request --> This PR fixed the following issues in `hoppscotch-backend` package 1. Improve SMTP email validation by allowing a total of 3 formats that the nodemailer npm package allows. https://nodemailer.com/message/addresses. This error encountered when `updateInfraConfigs` mutation called. 2. To resolve error on `enableAndDisableSSO` mutation, introduced Database call `findMany()` instead of `configService.get()` to get latest data <!-- You can also choose to add a list of changes and if they have been completed or not by using the markdown to-do list syntax - [ ] Not Completed - [x] Completed --> ### Current Problem 1. Regarding the SMTP email format The npm Nodemailer package has 3 acceptable formats where `hoppscotch-backend` previously accepts only email as `MAILER_ADDRESS_FROM`. ``` Backend Server | [Nest] 65 - 12/19/2023, 5:46:40 PM ERROR [ExceptionsHandler] infra_config/invalid_input Backend Server | Error: infra_config/invalid_input Backend Server | at throwErr (/usr/src/app/packages/hoppscotch-backend/dist/utils.js:14:11) Backend Server | at InfraResolver.updateInfraConfigs (/usr/src/app/packages/hoppscotch-backend/dist/admin/infra.resolver.js:121:34) ``` 2. When `enableAndDisableSSO` mutation called, is checks `isServiceConfigured` with old data from `configService` instead of new data from database. ``` { "errors": [ { "message": "infra_config/service_not_configured", "locations": [ { "line": 2, "column": 3 } ], "path": [ "enableAndDisableSSO" ], "extensions": { "code": "INTERNAL_SERVER_ERROR", "stacktrace": [ "Error: infra_config/service_not_configured", " at throwErr (/usr/src/app/packages/hoppscotch-backend/dist/utils.js:14:11)", " at InfraConfigService.enableAndDisableSSO (/usr/src/app/packages/hoppscotch-backend/dist/infra-config/infra-config.service.js:167:42)", " at InfraResolver.enableAndDisableSSO (/usr/src/app/packages/hoppscotch-backend/dist/admin/infra.resolver.js:131:57)", " at /usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/helpers/external-context-creator.js:67:33", " at async target (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/helpers/external-context-creator.js:74:28)", " at async Object.enableAndDisableSSO (/usr/src/app/node_modules/.pnpm/@nestjs+core@10.2.7_@nestjs+common@10.2.7_@nestjs+platform-express@10.2.7_reflect-metadata@0.1.13_rxjs@7.6.0/node_modules/@nestjs/core/helpers/external-proxy.js:9:24)" ] } } ], "data": null } ``` ### Testing Instruction 1. Test `updateInfraConfigs` mutation to update `MAILER_ADDRESS_FROM` 2. Test `enableAndDisableSSO` mutation ### Checks <!-- Make sure your pull request passes the CI checks and do check the following fields as needed - --> - [x] My pull request adheres to the code style of this project - [ ] My code requires changes to the documentation - [ ] I have updated the documentation as required - [x] All the tests have passed ### Additional Information <!-- Any additional information like breaking changes, dependencies added, screenshots, comparisons between new and old behaviour, etc. --> Nil --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-17 02:01:29 +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/hoppscotch#4491
No description provided.