[GH-ISSUE #3037] CSV Import conatining duplicates #1738

Closed
opened 2026-02-27 11:18:52 +03:00 by kerem · 3 comments
Owner

Originally created by @dorsax on GitHub (Aug 3, 2023).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/3037

Impacted versions

  • OS Type: Ubuntu
  • OS Version: 22.04 LTS
  • Database Type: Postgres
  • Database version: 8
  • Modoboa: 2.1.2
  • installer used: Yes
  • Webserver: Nginx

Steps to reproduce

  1. Create domain example.com
  2. Create a user mailbox@example.com
  3. Create the following csv:
alias; user1@example.com; mailbox@example.com
alias; user2@example.com; mailbox@example.com
alias; user3@example.com; mailbox@example.com
alias; user1@example.com; mailbox@example.com

Current behavior

  • Use the import on the new-admin: Site is not responding, webserver is reporting Status Code 500
  • use the cli import and you get an error
    Note: Even when checking to continue on duplicates (CLI and Web) creates the same issue

Expected behavior

Error handling which explains what to do, maybe even on which line the problem is.
Then to propagate this error on the cli as well as on the new admin.

Originally created by @dorsax on GitHub (Aug 3, 2023). Original GitHub issue: https://github.com/modoboa/modoboa/issues/3037 # Impacted versions * OS Type: Ubuntu * OS Version: 22.04 LTS * Database Type: Postgres * Database version: 8 * Modoboa: 2.1.2 * installer used: Yes * Webserver: Nginx # Steps to reproduce 1. Create domain example.com 1. Create a user mailbox@example.com 2. Create the following csv: ```csv alias; user1@example.com; mailbox@example.com alias; user2@example.com; mailbox@example.com alias; user3@example.com; mailbox@example.com alias; user1@example.com; mailbox@example.com ``` # Current behavior - Use the import on the new-admin: Site is not responding, webserver is reporting Status Code 500 - use the cli import and you get an error Note: Even when checking to continue on duplicates (CLI and Web) creates the same issue # Expected behavior Error handling which explains what to do, maybe even on which line the problem is. Then to propagate this error on the cli as well as on the new admin.
kerem closed this issue 2026-02-27 11:18:52 +03:00
Author
Owner

@Spitfireap commented on GitHub (Aug 4, 2023):

Hi, the right format for alias csv import is

alias; alias@domain.tld, enabled, recipient, [more recipients,...]

With enabled being : ["true", "1", "yes", "y"] or anything else to have the alias disabled.

<!-- gh-comment-id:1665523998 --> @Spitfireap commented on GitHub (Aug 4, 2023): Hi, the right format for alias csv import is ```alias; alias@domain.tld, enabled, recipient, [more recipients,...]``` With enabled being : ["true", "1", "yes", "y"] or anything else to have the alias disabled.
Author
Owner

@dorsax commented on GitHub (Aug 6, 2023):

Well, that was my mistake when I created the issue, but the missing column wasn't the cause.
Here is the 'testident.csv' which works to fail:

alias; user1@example.com;True; mailbox@example.com
alias; user2@example.com;True; mailbox@example.com
alias; user3@example.com;True; mailbox@example.com
alias; user1@example.com;True; mailbox@example.com

And this is the complete command and output from the cli:

(env) modoboa@se:~/instance$ python manage.py modo import testident.csv --continue-if-exists
Traceback (most recent call last):######################################################################################################################################################################                                                                  |ETA:  0:00:00  File "/srv/modoboa/instance/manage.py", line 22, in <module>
    main()
  File "/srv/modoboa/instance/manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/management/commands/modo.py", line 50, in execute
    return options.pop('command').execute(*args, **options)
  File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/management/commands/subcommands/_import.py", line 88, in handle
    self._import(filename, options)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/management/commands/subcommands/_import.py", line 70, in _import
    fct(superadmin, row, options)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/lib.py", line 169, in import_alias
    _import_alias(user, row, expected_elements=4)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/lib.py", line 165, in _import_alias
    alias.from_csv(user, row, **kwargs)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/models/alias.py", line 217, in from_csv
    local_part, self.domain = validate_alias_address(self.address, user)
  File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/models/alias.py", line 37, in validate_alias_address
    raise ValidationError(_("An alias with this name already exists."))
django.core.exceptions.ValidationError: ['An alias with this name already exists.']
<!-- gh-comment-id:1666779565 --> @dorsax commented on GitHub (Aug 6, 2023): Well, that was my mistake when I created the issue, but the missing column wasn't the cause. Here is the 'testident.csv' which works to fail: ``` alias; user1@example.com;True; mailbox@example.com alias; user2@example.com;True; mailbox@example.com alias; user3@example.com;True; mailbox@example.com alias; user1@example.com;True; mailbox@example.com ``` And this is the complete command and output from the cli: ``` (env) modoboa@se:~/instance$ python manage.py modo import testident.csv --continue-if-exists Traceback (most recent call last):###################################################################################################################################################################### |ETA: 0:00:00 File "/srv/modoboa/instance/manage.py", line 22, in <module> main() File "/srv/modoboa/instance/manage.py", line 18, in main execute_from_command_line(sys.argv) File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line utility.execute() File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/__init__.py", line 413, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/base.py", line 354, in run_from_argv self.execute(*args, **cmd_options) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/management/commands/modo.py", line 50, in execute return options.pop('command').execute(*args, **options) File "/srv/modoboa/env/lib/python3.10/site-packages/django/core/management/base.py", line 398, in execute output = self.handle(*args, **options) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/management/commands/subcommands/_import.py", line 88, in handle self._import(filename, options) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/management/commands/subcommands/_import.py", line 70, in _import fct(superadmin, row, options) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/lib.py", line 169, in import_alias _import_alias(user, row, expected_elements=4) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/lib.py", line 165, in _import_alias alias.from_csv(user, row, **kwargs) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/models/alias.py", line 217, in from_csv local_part, self.domain = validate_alias_address(self.address, user) File "/srv/modoboa/env/lib/python3.10/site-packages/modoboa/admin/models/alias.py", line 37, in validate_alias_address raise ValidationError(_("An alias with this name already exists.")) django.core.exceptions.ValidationError: ['An alias with this name already exists.'] ```
Author
Owner

@Spitfireap commented on GitHub (Aug 6, 2023):

oh crap my bad. Will fix it :)

<!-- gh-comment-id:1666794392 --> @Spitfireap commented on GitHub (Aug 6, 2023): oh crap my bad. Will fix it :)
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/modoboa-modoboa#1738
No description provided.