Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strange issue with Python 3.7 and 3.8 #20

Closed
ZviBaratz opened this issue Sep 5, 2021 · 3 comments
Closed

Strange issue with Python 3.7 and 3.8 #20

ZviBaratz opened this issue Sep 5, 2021 · 3 comments

Comments

@ZviBaratz
Copy link
Contributor

Hi,

I'm developing a Django application, and even though everything works fine in my local dev environment (Python 3.9), my CI build for Python 3.7 and 3.8 is failing (surprisingly, Python 3.6 is passing, and so is 3.9).
The exception I'm getting looks like this:

  File "/root/pylabber/accounts/models/__init__.py", line 9, in <module>
    from accounts.models.export_destination import ExportDestination
  File "/root/pylabber/accounts/models/export_destination.py", line 15, in <module>
    class ExportDestination(TitleDescriptionModel):
  File "/root/pylabber/accounts/models/export_destination.py", line 29, in ExportDestination
    password = fields.EncryptedCharField(
  File "/root/pylabber/.tox/py38-django3/lib/python3.8/site-packages/mirage/fields.py", line 13, in __init__
    self.crypto = Crypto(key)
  File "/root/pylabber/.tox/py38-django3/lib/python3.8/site-packages/mirage/crypto.py", line 60, in __init__
    assert len(key) >= 32, "mirage key length must more than 32!"
AssertionError: mirage key length must more than 32!

The relevant field definition looks like:

class ExportDestination(TitleDescriptionModel):
    ...
    password = fields.EncryptedCharField(
        max_length=128, blank=False, null=False
    )

Any help figuring out the cause for this would be greatly appreciated.
Thanks for all your great work,
Zvi

@tcitry
Copy link
Member

tcitry commented Sep 5, 2021

Hi @ZviBaratz

Are you make sure your MIRAGE_SECRET_KEY or SECRET_KEY in settings.py that length is >= 32?

or maybe something wrong in your CI environment variable, did you set it in CI ?

ZviBaratz added a commit to ZviBaratz/django-mirage-field that referenced this issue Sep 5, 2021
Proposing a different message for short secret keys, following luojilab#20.
@ZviBaratz
Copy link
Contributor Author

Well, that's embarrassing. I forgot about the default SECRET_KEY setting used in the CI environment.
I made a tiny PR with a more verbose message for that exception, hope you agree it's a little clearer (there is also a small typo in the current one).
Thank you very much for your support!

@tcitry
Copy link
Member

tcitry commented Sep 5, 2021

That's great! Thanks for your PR.

@tcitry tcitry closed this as completed Sep 5, 2021
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

No branches or pull requests

2 participants