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

do not migrate old credentials if decryption fails #2929

Open
ljain112 opened this issue Jan 7, 2025 · 0 comments
Open

do not migrate old credentials if decryption fails #2929

ljain112 opened this issue Jan 7, 2025 · 0 comments

Comments

@ljain112
Copy link
Collaborator

ljain112 commented Jan 7, 2025

Installation fails if encryption key is not valid.

App erpnext already installed

Installing india_compliance...
Updating DocTypes for india_compliance: [========================================] 100%
Setting up Income Tax...
Setting up GST...
Patching Existing Data...
Installation for India Compliance failed due to an error. Please try re-installing the app or report the issue on https://github.com/resilient-tech/india-compliance/issues/new if not resolved.
An error occurred while installing india_compliance: Fernet key must be 32 url-safe base64-encoded bytes.
Traceback with variables (most recent call last):
  File "apps/frappe/frappe/commands/site.py", line 478, in install_app
    _install_app(app, verbose=context.verbose, force=force)
      context = {'sites': ['pispl.frappe.cloud'], 'force': False, 'verbose': False, 'profile': False}
      apps = ('india_compliance',)
      force = True
      _install_app = <function install_app at 0x7fa124b97ce0>
      filelock = <function filelock at 0x7fa124b95440>
      exit_code = 0
      site = 'pispl.frappe.cloud'
      app = 'india_compliance'
      err = ValueError('Fernet key must be 32 url-safe base64-encoded bytes.')
  File "apps/frappe/frappe/installer.py", line 326, in install_app
    frappe.get_attr(after_install)()
      name = 'india_compliance'
      verbose = False
      set_as_patched = True
      force = True
      sync_jobs = <function sync_jobs at 0x7fa123eb3e20>
      sync_for = <function sync_for at 0x7fa123ec4e00>
      sync_customizations = <function sync_customizations at 0x7fa1255c1260>
      sync_fixtures = <function sync_fixtures at 0x7fa123ec5120>
      app_hooks = {'accounting_dimension_doctypes': ['Bill of Entry', 'Bill of Entry Item'], 'after_app_install': ['india_compliance.install.after_app_install'], 'after_install': ['india_compliance.install.after_install'], 'after_migrate': ['india_compliance.audit_trail.setup.after_migrate'], 'app_color': ['grey'], 'app_description': ['ERPNext app to simplify compliance with Indian Rules and Regulations'], 'app_email': ['[email protected]'], 'app_icon': ['octicon octicon-file-directory'], 'app_include_js': ['india_compliance.bundle.js'], 'app_license': ['GNU General Public License (v3)'], 'app_name': ['india_compliance'], 'app_publisher': ['Resilient Tech'], 'app_title': ['India Compliance'], 'audit_trail_doctypes': ['Accounts Settings', 'Dunning', 'Invoice Discounting', 'Journal Entry', 'Payment Entry', 'Period Closing Voucher', 'Process Deferred Accounting', 'Purchase Invoice', 'Sales Invoice', 'Asset', 'Asset Capitalization', 'Asset Repair', 'Delivery Note', 'Landed Cost Voucher', 'Purchase R...
      installed_apps = ['frappe', 'erpnext', 'india_compliance']
      app = 'frappe/erpnext'
      required_app = 'erpnext'
      before_install = 'india_compliance.patches.check_version_compatibility.execute'
      out = None
      after_install = 'india_compliance.install.after_install'
  File "apps/india_compliance/india_compliance/install.py", line 78, in after_install
    raise e
  File "apps/india_compliance/india_compliance/install.py", line 67, in after_install
    run_post_install_patches()
  File "apps/india_compliance/india_compliance/install.py", line 91, in run_post_install_patches
    frappe.get_attr(f"india_compliance.patches.post_install.{patch}.execute")()
      patch = 'migrate_e_invoice_settings_to_gst_settings'
  File "apps/india_compliance/india_compliance/patches/post_install/migrate_e_invoice_settings_to_gst_settings.py", line 27, in execute
    if old_credentials := get_credentials_from_e_invoice_user():
      singles = Table('tabSingles')
      old_settings = {'applicable_from': '2022-04-18', 'enable': '1'}
      gst_settings = <GSTSettings: GST Settings>
  File "apps/india_compliance/india_compliance/patches/post_install/migrate_e_invoice_settings_to_gst_settings.py", line 66, in get_credentials_from_e_invoice_user
    credential.password = credential.password and decrypt(credential.password)
    cipher_suite = Fernet(encode(encryption_key or get_encryption_key()))
      encryption_key = ********
      key = ********
  File "env/lib/python3.11/site-packages/cryptography/fernet.py", line 36, in __init__
    raise ValueError(
      self = <cryptography.fernet.Fernet object at 0x7fa1211c3950>
      key = ********
      backend = None
builtins.ValueError: Fernet key must be 32 url-safe base64-encoded bytes.

https://support.frappe.io/app/hd-ticket/28859

Huly®: IC-3056

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

1 participant