abhishek-ram / pyas2

This repo is no longer maintained and has been moved to https://github.com/abhishek-ram/django-pyas2
GNU General Public License v2.0
47 stars 23 forks source link

Requesting MDN From Partner Error #8

Closed mreinigjr closed 9 years ago

mreinigjr commented 9 years ago

Hello,

When requesting an MDN from partner I receive the following error with traceback:

20150628 19:09:37 INFO     : Send message started with parameters: "['/usr/bin/python', '/home/testserver/django_pyas2/manage.py', 'sendas2message', u'test1', u'test2', u'/tmp/test.txtxjxflq']"
System check identified some issues:

WARNINGS:
?: (1_6.W001) Some project unittests may not execute as expected.
HINT: Django 1.6 introduced a new default test runner. It looks like this project was generated using Django 1.5 or earlier. You should ensure your tests are all running & behaving as expected. See https://docs.djangoproject.com/en/dev/releases/1.6/#new-test-runner for more information.
20150628 19:09:37 DEBUG    : Sender Mic content 
MIME-Version: 1.0
Content-Type: application/pkcs7-mime; name="smime.p7z"; smime-type="compressed-data"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="smime.p7z"

MIAGCyqGSIb3DQEJEAEJoIAwgAIBADCABgsqhkiG9w0BCRADCAAAMIAGCSqGSIb3DQEHAaCABGJ4
nC3KMQ6AIBAF0Z6EOxh7tddY4RG8AMElroEFwy/w9mJiO/NMEpBg2J9Mc2dzDuwsOMlEBw8uSWlX
K/OzjUtOhT/QNGDdGVtfOs+BxEZae1DBiIp6VR/uXiutvvQCFhgmTgAAAAAAAAAAAAA=

Traceback (most recent call last):
  File "/home/testserver/django_pyas2/manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 377, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 288, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 338, in execute
    output = self.handle(*args, **options)
  File "/usr/local/lib/python2.7/dist-packages/pyas2/management/commands/sendas2message.py", line 54, in handle
    message.save()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 589, in save
    force_update=force_update, update_fields=update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 617, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 679, in _save_table
    forced_update)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 723, in _do_update
    return filtered._update(values) > 0
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 600, in _update
    return query.get_compiler(self.db).execute_sql(CURSOR)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 1005, in execute_sql
    cursor = super(SQLUpdateCompiler, self).execute_sql(result_type)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 787, in execute_sql
    cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 81, in execute
    return super(CursorDebugWrapper, self).execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
  File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 94, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/utils.py", line 65, in execute
    return self.cursor.execute(sql, params)
django.db.utils.DataError: value too long for type character varying(2)

Here is the log messages from pyas2 admin:

image

SOLUTION

The problem originates from table pyas2_message, column mdn_mode. Here the options from models.py can only be "ASYNC" or "SYNC". varchar(2) will not be enough to hold either of these values and needs to be updated to at least varchar(5). After changing to varchar(5). The issue is eliminated.

Thanks!

abhishek-ram commented 9 years ago

Thank you for pointing this out. I am nit sure why I did not face this error.

Can you please clone the repo, make the change and submit a PR?